Using push_back on a vector of strings - C++ - c++

I am trying to use push_back on a vector of strings in C++. How can I push a single character on to the vector? Currently, I have tried the following, all without success:
Initialized a string (tried to) with the character.
Code
string str(main_string[0]);
vector_string.push_back(str);
Tried to invoke strcpy and thus copy contents. Const-ness seems to get in the way.
Code
string str;
strcpy(main_string[0], str.c_str());
vector_string.push_back(str);
Any more suggestions/ideas are most welcome.
Edit: The error logs are as follows:
test_push.C: In function ‘void test_push(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::string)’:
test_push.C:50: error: no matching function for call to ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char&)’
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:220: note: candidates are: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(typename _Alloc::rebind<_CharT>::other::size_type, _CharT, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:213: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:206: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, typename _Alloc::rebind<_CharT>::other::size_type, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:194: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, typename _Alloc::rebind<_CharT>::other::size_type, typename _Alloc::rebind<_CharT>::other::size_type, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:184: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, typename _Alloc::rebind<_CharT>::other::size_type, typename _Alloc::rebind<_CharT>::other::size_type) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:170: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:178: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.h:2147: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
test_push.C:61: error: conversion from ‘char’ to non-scalar type ‘std::string’ requested
test_push:90: error: no matching function for call to ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char&)’
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:220: note: candidates are: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(typename _Alloc::rebind<_CharT>::other::size_type, _CharT, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:213: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/bits/basic_string.tcc:206: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, typename _Alloc::rebind<_CharT>::other::size_type, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
More info: In this function, either the entire string or just the first letter is pushed in to the vector based on its contents. So, in a way, I am looking for some function that converts a char into a C++ style std::string (to make it acceptable to a vector).
Thanks,
Sriram

You can also initialize with one character like this.
string str(1,main_string[0]);
vector_string.push_back(str);

You can add the character directly via an appropriate string constructor:
vector_string.push_back(string(1, main_string[0]));
EDIT: Removed alternate solution after realising it duplicates #Tim's.

no need for strcpy for a single character.
string str ("x");
str[0] = main_string[0];
vector_string.push_back(str);

Related

Why boost::replace_all_copy is not working? C++

I am trying to make working code to replace text of line. Using boost_1_64_0 .
getline (ifs, line);
cout << line << endl;
// 1.
boost::replace_all(line, "abc", "hij");
boost::replace_all(line, "def", "klm");
// 2.
line = boost::replace_all_copy
boost::replace_all_copy<string>
(
("abc def abc def", "abc", "hij")
, "def"
, "klm"
);
I am getting these errors:
main.cpp||In function 'int main()':|
main.cpp|37|error: no match for 'operator=' in 'line = boost::algorithm::replace_all_copy'|
main.cpp|37|note: candidates are:|
\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|543|note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>]|
mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|543|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::basic_string<char>&'|
mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|551|note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>]|
mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|551|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const char*'|
mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|562|note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>]|
mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|562|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'char'|
main.cpp|38|error: expected ';' before 'boost'|
main.cpp|53|error: expected '}' before 'else'|
Why the error happens or how can I correct them?
You have written obviously broken code:
line = boost::replace_all_copy boost::replace_all_copy<string>(...)

error while working with boost::sregex_token_iterator

I want to search for a regular expression and print it with a color. I used boost::sregex_token_iterator to do this. this is my code
boost::regex re("ab.");
string s="";
string buf;
string infile("retest.txt");
//string color="green";
ifstream in(infile.c_str());
int lcount=0;
while (getline(in,buf))
{
boost::sregex_token_iterator p(buf.begin(), buf.end(), re, 0);
boost::sregex_token_iterator end;
lcount++;
cout <<"line : "<<lcount<<endl;
for (;p != end;++p)
{
string m(p->first, p->second);
cout<< m <<endl;
//cout <<*(p->first)<<endl;
//cout <<*(p->second)<<endl;
//unsigned int pos = buf.find(m);
buf = buf.insert(p->first,"\e[0;32m");
buf = buf.insert(p->second+m.length()+7,"\e[0m");
}
cout<<"\n";
s.append(buf);
s.append("\n");
}
in.close();
cout <<"s is: "<<s<<endl;
return 0;
}
but I get this error :
In file included from /usr/include/boost/config.hpp:35:0,
from /usr/include/boost/regex/config.hpp:53,
from /usr/include/boost/regex.hpp:28,
from main3.cc:3:
/usr/include/boost/config/compiler/gcc.hpp:92:7: warning: #warning "Unknown compiler version - please run the configure tests and report the results" [-Wcpp]
main3.cc: In function âint main(int, char**)â:
main3.cc:36:40: error: no matching function for call to âstd::basic_string::insert(const __gnu_cxx::__normal_iterator >&, const char [8])â
main3.cc:36:40: note: candidates are:
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:54:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1182:7: note: void std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator >; typename _Alloc::rebind<_CharT>::other::pointer = char*; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1182:7: note: candidate expects 3 arguments, 2 provided
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1199:9: note: template void std::basic_string::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1199:9: note: template argument deduction/substitution failed:
main3.cc:36:40: note: cannot convert âp.boost::regex_token_iterator::operator-><__gnu_cxx::__normal_iterator >, char, boost::regex_traits, std::allocator >()->boost::sub_match<__gnu_cxx::__normal_iterator > >::.std::pair<__gnu_cxx::__normal_iterator >, __gnu_cxx::__normal_iterator > >::firstâ (type âconst __gnu_cxx::__normal_iterator >â) to type âstd::basic_string::iterator {aka __gnu_cxx::__normal_iterator >}â
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:54:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1230:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1230:7: note: no known conversion for argument 1 from âconst __gnu_cxx::__normal_iterator >â to âstd::basic_string::size_type {aka unsigned int}â
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1252:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1252:7: note: candidate expects 4 arguments, 2 provided
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:55:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.tcc:361:6: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.tcc:361:6: note: candidate expects 3 arguments, 2 provided
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:54:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1293:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1293:7: note: no known conversion for argument 1 from âconst __gnu_cxx::__normal_iterator >â to âstd::basic_string::size_type {aka unsigned int}â
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1316:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1316:7: note: candidate expects 3 arguments, 2 provided
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1334:7: note: std::basic_string<_CharT, _Traits, _Alloc>::iterator std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, _CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator >; typename _Alloc::rebind<_CharT>::other::pointer = char*]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1334:7: note: no known conversion for argument 1 from âconst __gnu_cxx::__normal_iterator >â to âstd::basic_string::iterator {aka __gnu_cxx::__normal_iterator >}â
main3.cc:37:51: error: no matching function for call to âstd::basic_string::insert(__gnu_cxx::__normal_iterator >, const char [5])â
main3.cc:37:51: note: candidates are:
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:54:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1182:7: note: void std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator >; typename _Alloc::rebind<_CharT>::other::pointer = char*; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1182:7: note: candidate expects 3 arguments, 2 provided
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1199:9: note: template void std::basic_string::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1199:9: note: template argument deduction/substitution failed:
main3.cc:37:51: note: cannot convert âp.boost::regex_token_iterator::operator-><__gnu_cxx::__normal_iterator >, char, boost::regex_traits, std::allocator >()->boost::sub_match<__gnu_cxx::__normal_iterator > >::.std::pair<__gnu_cxx::__normal_iterator >, __gnu_cxx::__normal_iterator > >::second.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+ >((* &((__gnu_cxx::__normal_iterator >::difference_type)m.std::basic_string<_CharT, _Traits, Alloc>::length, std::allocator >())))._gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+ >((* &7))â (type â__gnu_cxx::__normal_iterator >â) to type âstd::basic_string::iterator {aka __gnu_cxx::__normal_iterator >}â
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:54:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1230:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1230:7: note: no known conversion for argument 1 from â__gnu_cxx::__normal_iterator >â to âstd::basic_string::size_type {aka unsigned int}â
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1252:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1252:7: note: candidate expects 4 arguments, 2 provided
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:55:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.tcc:361:6: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.tcc:361:6: note: candidate expects 3 arguments, 2 provided
In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/string:54:0,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/locale_classes.h:42,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/ios_base.h:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ios:43,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/ostream:40,
from /usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/iostream:40,
from main3.cc:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1293:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1293:7: note: no known conversion for argument 1 from â__gnu_cxx::__normal_iterator >â to âstd::basic_string::size_type {aka unsigned int}â
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1316:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1316:7: note: candidate expects 3 arguments, 2 provided
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1334:7: note: std::basic_string<_CharT, _Traits, _Alloc>::iterator std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, _CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator >; typename _Alloc::rebind<_CharT>::other::pointer = char*]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/basic_string.h:1334:7: note: no known conversion for argument 1 from â__gnu_cxx::__normal_iterator >â to âstd::basic_string::iterator {aka __gnu_cxx::__normal_iterator >}â
I know that the type of p->first is not the one which insert function accepts. but I don't know how to convert these to each other.
The issue might be your usage of std::string::insert. I can't see an insert(iterator, string) version among it's numerous overloads.
You might want to call desired version by explicitly stating length of char array:
void insert (iterator p, size_t n, char c)
The problem seems to be that boost is configured for use with a different version of the compiler rather than the one you are currently using.
Could you add the details of how you compiled it as well?

Trying to build muParser: error: explicit instantiation of 'std::basic_ostream but no definition available

Im trying to build muParser on the mac, it worked until I upgraded XCode to 4.4 which updated gcc. Now I get the following line of code generating the error which I don't understand:
mu::console() << _T(" \"") << val.GetAsString() << _T("\" ");
../muparser/src/muParserBase.cpp:1823: instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../muparser/src/muParserBase.cpp: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../muparser/src/muParserBase.cpp:1823: instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../muparser/src/muParserBase.cpp: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../muparser/src/muParserBase.cpp:1823: instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../muparser/src/muParserBase.cpp: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../muparser/src/muParserBase.cpp:1823: instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
mu::console() is define as:
inline std::ostream& console()
{
return std::cout;
}
_T is #define _T(x) x
and GetAsString
const TString& GetAsString() const
{
return m_strTok;
}
TString is a std::string
It is the call to GetAsString that causes the problem. Any idea how to fix it?
Add these two lines to your .pro file and the error will go away:
QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.7
QMAKE_CXXFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64
It looks like you are linking the wrong standard library or including the wrong C++ includes. You will want to make sure your include path c++ headers matches the standard library you are linking.
If you post your build file, I can help see if there is a mismatch.
When I upgraded to XCode 4.4.x, the Command Line Tools were removed. In XCode, I wend to XCode > Preferences, selected the Downloads tab, and re-downloaded "Command Line Tools" and then things started to work again. Maybe this will fix your problem too?

defining a template c++

This is a noob question sorry :(
I dont know why this gives me an error..could somebody please explain?
for example i wanna do:
vector<double> a;
string s("0.11 11.0002");
copys(s, a);
template <typename T, typename S>
void copys(T& c, S& d)
{
istringstream iss(c);
copy(istream_iterator<S>(iss), istream_iterator<S>(),
back_inserter(d));
return;
}
The error from the compiler is:
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stream_iterator.h: In member function `void std::istream_iterator<_Tp, _CharT, _Trai
ts, _Dist>::_M_read() [with _Tp = std::vector<double, std::allocator<double> >, _CharT = char, _Traits = std::char_traits<char>, _Dist
= int]':
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stream_iterator.h:68: instantiated from `std::istream_iterator<_Tp, _CharT, _Trait
s, _Dist>::istream_iterator(std::basic_istream<_CharT, _Traits>&) [with _Tp = std::vector<double, std::allocator<double> >, _CharT = ch
ar, _Traits = std::char_traits<char>, _Dist = int]'
ProfitCalculator.cpp:20: instantiated from `void copys(T&, S&) [with T = std::basic_string<char, std::char_traits<char>, std::allocat
or<char> >, S = std::vector<double, std::allocator<double> >]'
ProfitCalculator.cpp:41: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stream_iterator.h:119: error: no match for `operator>>' in `*((std::istream_iterator
<std::vector<double, std::allocator<double> >, char, std::char_traits<char>, int>*)this)->std::istream_iterator<std::vector<double, std
::allocator<double> >, char, std::char_traits<char>, int>::_M_stream >> ((std::istream_iterator<std::vector<double, std::allocator<doub
le> >, char, std::char_traits<char>, int>*)this)->std::istream_iterator<std::vector<double, std::allocator<double> >, char, std::char_t
raits<char>, int>::_M_value'
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:123: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Tr
aits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:127: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = s
td::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:134: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:170: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(bool&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:174: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(short int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:177: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:181: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:184: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:188: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(long int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:192: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:197: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:201: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:206: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(float&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:210: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(double&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:214: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(long double&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:218: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(void*&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/istream:242: note: std::basic_istream<_CharT, _Traits>& std::basic_istrea
m<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stl_algobase.h: In static member function `static _OI std::__copy_move<<anonymous>,
<anonymous>, <template-parameter-1-3> >::__copy_m(_II, _II, _OI) [with _II = std::istream_iterator<std::vector<double, std::allocator<d
ouble> >, char, std::char_traits<char>, int>, _OI = std::back_insert_iterator<std::vector<double, std::allocator<double> > >, bool <ano
nymous> = false, bool <anonymous> = false, <template-parameter-1-3> = std::input_iterator_tag]':
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stl_algobase.h:396: instantiated from `_OI std::__copy_move_a(_II, _II, _OI) [with
bool _IsMove = false, _II = std::istream_iterator<std::vector<double, std::allocator<double> >, char, std::char_traits<char>, int>, _O
I = std::back_insert_iterator<std::vector<double, std::allocator<double> > >]'
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stl_algobase.h:435: instantiated from `_OI std::__copy_move_a2(_II, _II, _OI) [wit
h bool _IsMove = false, _II = std::istream_iterator<std::vector<double, std::allocator<double> >, char, std::char_traits<char>, int>, _
OI = std::back_insert_iterator<std::vector<double, std::allocator<double> > >]'
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stl_algobase.h:466: instantiated from `_OI std::copy(_II, _II, _OI) [with _II = st
d::istream_iterator<std::vector<double, std::allocator<double> >, char, std::char_traits<char>, int>, _OI = std::back_insert_iterator<s
td::vector<double, std::allocator<double> > >]'
ProfitCalculator.cpp:20: instantiated from `void copys(T&, S&) [with T = std::basic_string<char, std::char_traits<char>, std::allocat
or<char> >, S = std::vector<double, std::allocator<double> >]'
ProfitCalculator.cpp:41: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stl_algobase.h:312: error: no match for `operator=' in `__result.std::back_insert_it
erator<_Container>::operator* [with _Container = std::vector<double, std::allocator<double> >]() = __first.std::istream_iterator<_Tp, _
CharT, _Traits, _Dist>::operator* [with _Tp = std::vector<double, std::allocator<double> >, _CharT = char, _Traits = std::char_traits<c
har>, _Dist = int]()'
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stl_iterator.h:412: note: candidates are: std::back_insert_iterator<_Container>& std
::back_insert_iterator<_Container>::operator=(typename _Container::const_reference) [with _Container = std::vector<double, std::allocat
or<double> >]
/usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/stl_iterator.h:388: note: std::back_insert_iterator<std::vector<doub
le, std::allocator<double> > >& std::back_insert_iterator<std::vector<double, std::allocator<double> > >::operator=(const std::back_ins
ert_iterator<std::vector<double, std::allocator<double> > >&)
make: *** [ProfitCalculator] Error 1
The problem is that after template substitution, this
copy(istream_iterator<S>(iss), istream_iterator<S>(),
back_inserter(d));
becomes
copy(istream_iterator<vector<double> >(iss), istream_iterator<vector<double> >(),
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
back_inserter(d));
You don't want to extract vector<double>-s from the string (and stringstreams can't do that anyway). Instead you want to extract double-s from the string, and therefore you need the value_type of the vector (double in this case).
typedef typename S::value_type value_type;
copy(istream_iterator<value_type>(iss), istream_iterator<value_type>(),
back_inserter(d));
It's hard to say for sure without the error, but I see two potential problems:
Your template definition comes after its use, so the compiler doesn't know what copys(...) is supposed to be.
a vector<double> can't .push_back(std::string), and there's nothing in copys that I can see what would convert from a string representation to a double.
Update:
Alright, given the error in your question, I'd say the answer is #2.

gcc linker errors when using boost to_lower & trim

I'm trying to use the boost library in my code but get the following linker errors under Sparc Solaris platform.
The problem code can essentially be summarised to:
#include <boost/algorithm/string.hpp>
std::string xparam;
...
xparam = boost::to_lower(xparam);
The linker error is:
LdapClient.cc:349: no match for `std::string& = void' operator
/opt/gcc-3.2.3/include/c++/3.2.3/bits/basic_string.h:338: candidates are: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/opt/gcc-3.2.3/include/c++/3.2.3/bits/basic_string.h:341: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/opt/gcc-3.2.3/include/c++/3.2.3/bits/basic_string.h:344: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
gmake: *** [LdapClient.o] Error 1
Any ideas?
boost::to_lower does not return a copy of the string, it operates on the variable passed into the function. For some examples, read this.
So no need to reassign:
boost::to_lower(xparam);
You will get an error because you are trying to assign the string to the value void.
If you want to make a copy of it, use the copy version:
std::string xparamLowered = boost::to_lower_copy(xparam);
boost::to_lower modifies the string in-place, it does not return a new string. This is sufficient:
boost::to_lower(xparam);
And your code doesn't compile because the return type of to_lower is void (as the error message says).