no match for operator+ error in c++ - c++

Here is the Rational class that i've been working on:
rational.h
#include<iostream>
using namespace std;
#ifndef RATIONAL_H
#define RATIONAL_H
class Rational
{
int numerator,denominator;
public:
// the various constructors
Rational();
Rational(int);
Rational(int,int);
//member functions
int get_numerator()const{return numerator;}
int get_denominator()const{return denominator;}
// overloaded operators
// relational operators
bool operator==(const Rational&)const;
bool operator<(const Rational&)const;
bool operator<=(const Rational&)const;
bool operator>(const Rational&)const;
bool operator>=(const Rational&)const;
//arithmetic operators
Rational operator+(const Rational&);
Rational operator-(const Rational&);
Rational operator*(const Rational&);
Rational operator/(const Rational&);
//output operator
friend ostream& operator<<(ostream&, const Rational&);
};
#endif //RATIONAL_H
rational.cpp
#include "rational.h"
// implementation ofthe various constructors
Rational::Rational()
:numerator(0),denominator(1){}
Rational::Rational(int number)
:numerator(number),denominator(1){}
Rational::Rational(int n,int d)
:numerator(n),denominator(d)
{
if(denominator == 0) denominator = 1;
if(denominator < 0)
{
numerator *= -1;
denominator *= -1;
}
}
// implementation of overloaded operators
bool Rational::operator==(const Rational& rhs)const
{
if( numerator * rhs.get_denominator() == denominator * rhs.get_numerator() )
{
return true;
}
else return false;
}
bool Rational::operator<(const Rational& rhs)const
{
if( numerator * rhs.get_denominator() < denominator * rhs.get_numerator() )
{
return true;
}
else return false;
}
bool Rational::operator<=(const Rational& rhs)const
{
return operator==(rhs) || operator<(rhs);
}
bool Rational::operator>(const Rational& rhs)const
{
return !operator<(rhs);
}
bool Rational::operator>=(const Rational& rhs)const
{
return operator==(rhs) || operator>(rhs);
}
//arithmetic operators
Rational Rational::operator+(const Rational& rhs)
{
return Rational( (numerator * rhs.get_denominator() + denominator*rhs.get_numerator()), (denominator * rhs.get_denominator()) );
}
Rational Rational::operator-(const Rational& rhs)
{
//reuse of the + operator for substraction
return operator+(Rational(-1*rhs.get_numerator(),rhs.get_denominator()));
}
Rational Rational::operator*(const Rational& rhs)
{
return Rational(numerator * rhs.get_numerator(), denominator * rhs.get_denominator());
}
Rational Rational::operator/(const Rational& rhs)
{
//reuse of the * operator as division is the inverse of multiplication
return operator*(Rational(rhs.get_denominator(),rhs.get_numerator()));
}
// friend output operator
ostream& operator<<(ostream& os, const Rational& r)
{
os<<r.get_numerator()<<"/"<<r.get_denominator();
return os;
}
and the driver for the program driver.cpp
#include "rational.h"
int main()
{
Rational r1(),r2(3),r3(11,3),tmp;
cout<<r1+r2<<endl;
cout<<r2<<endl;
cout<<r2-r3<<endl;
cout<<r2*r3<<endl;
cout<<r1/r3;
return 0;
}
Here's the error that i get when trying to compile it.
driver.cpp: In function ‘int main()’:
driver.cpp:6:12: error: no match for ‘operator+’ in ‘r1 + r2’
driver.cpp:6:12: note: candidates are:
/usr/include/c++/4.6/bits/stl_iterator.h:327:5: note: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/basic_string.h:2306:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.tcc:694:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.tcc:710:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2343:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/include/c++/4.6/bits/basic_string.h:2359:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
driver.cpp:10:12: error: no match for ‘operator/’ in ‘r1 / r3’
When I comment the lines where I use the operator+ and operator/, then the code works.
This baffles me as I have implemented the operator- using operator+ and similarly the operator/ using operator*.
So if one of them works, I'd figure that the other would work too.
Can someone please explain what I have done wrong here?
Edit
I get even more errors when I use the operator==
rational.cpp:22:6: error: prototype for ‘bool Rational::operator==(const Rational&)’ does not match any in class ‘Rational’
rational.h:23:8: error: candidate is: bool Rational::operator==(Rational)
rational.cpp:31:6: error: prototype for ‘bool Rational::operator<(const Rational&) const’ does not match any in class ‘Rational’
rational.h:24:8: error: candidate is: bool Rational::operator<(Rational)
driver.cpp: In function ‘int main()’:
driver.cpp:11:10: error: no match for ‘operator==’ in ‘r1 == tmp’
driver.cpp:11:10: note: candidates are:
/usr/include/c++/4.6/bits/postypes.h:218:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template<class _T1, class _T2> bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_T1>&, const std::allocator<_T2>&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template<class _Tp> bool std::operator==(const std::allocator<_Tp1>&, const std::allocator<_Tp1>&)
/usr/include/c++/4.6/bits/basic_string.h:2427:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2434:5: note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
/usr/include/c++/4.6/bits/basic_string.h:2448:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2460:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/include/c++/4.6/bits/streambuf_iterator.h:194:5: note: template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
What do these cryptic messages mean?

r1 isn't an object of type Rational, as you've declared it, it's a function taking no parameters and returning a Rational.
r1() + r2 would be a valid expression, but you probably meant to make r1 a Rational:
Rational r1,r2(3),r3(11,3),tmp;
Note that your operator+ is assymmetric w.r.t const. I normally recommend making operator+ a free function:
Rational operator+( const Rational&, const Rational& );
If you want it to be a member function it should probably be declared const:
Rational operator+( const Rational& ) const;

Related

Using my custom iterator with STL algorithms

I'm trying to create my own iterator, and I've got it working as expected with the std::generate algorithm. However, when I try std::max_element of std::find, I get some cryptic errors.
Here is the interface for my iterator:
template <typename GridT,
typename GridPtr,
typename GridRef,
template <typename> class ShapeT>
class GridIterator
{
public:
typedef GridIterator<GridT, GridPtr, GridRef, ShapeT> Iterator;
// Iterator traits - typedefs and types required to be STL compliant
typedef std::ptrdiff_t difference_type;
typedef typename GridT::Element value_type;
typedef typename GridT::Element* pointer;
typedef typename GridT::Element& reference;
typedef size_t size_type;
std::forward_iterator_tag iterator_category;
GridIterator(GridT& grid,
ShapeT<typename GridT::Resolution> shape,
Index iterStartIndex);
~GridIterator();
Iterator& operator++();
Iterator operator++(int);
typename GridT::Element& operator*();
typename GridT::Element* operator->();
bool operator!=(const GridIterator& rhs) const;
bool operator==(const GridIterator& rhs) const;
....
}
Using std::find, I get this error:
In file included from /usr/include/c++/4.6/algorithm:63:0,
from ./grid/Map_Grid.h:11,
from main.cpp:4: /usr/include/c++/4.6/bits/stl_algo.h: In function ‘_IIter
std::find(_IIter, _IIter, const _Tp&) [with _IIter =
Map::GridIterator<Map::Grid<double, int>, Map::Grid<double, int>,
Map::Grid<double, int>&, Map::Rectangle>, _Tp = int]’:
main.cpp:103:50: instantiated from here
/usr/include/c++/4.6/bits/stl_algo.h:4404:45: error: no matching
function for call to
‘__iterator_category(Map::GridIterator<Map::Grid<double, int>,
Map::Grid<double, int>, Map::Grid<double, int>&, Map::Rectangle>&)’
/usr/include/c++/4.6/bits/stl_algo.h:4404:45: note: candidate is:
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:202:5: note:
template typename std::iterator_traits::iterator_category
std::__iterator_category(const _Iter&)
With std::max_element :
In file included from /usr/include/c++/4.6/bits/char_traits.h:41:0,
from /usr/include/c++/4.6/ios:41,
from /usr/include/c++/4.6/ostream:40,
from /usr/include/c++/4.6/iostream:40,
from ./grid/Map_GridIterator.h:7,
from ./grid/Map_Grid.h:8,
from main.cpp:4: /usr/include/c++/4.6/bits/stl_algobase.h: In function ‘const _Tp&
std::max(const _Tp&, const _Tp&) [with _Tp =
Map::GridIterator<Map::Grid<double, int>, Map::Grid<double, int>,
Map::Grid<double, int>&, Map::Rectangle>]’: main.cpp:102:60:
instantiated from here /usr/include/c++/4.6/bits/stl_algobase.h:215:7:
error: no match for ‘operator<’ in ‘__a < __b’
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:207:5: note: template<class _T1,
class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&,
const std::pair<_T1, _T2>&)
/usr/include/c++/4.6/bits/stl_iterator.h:291:5: note: template bool std::operator<(const std::reverse_iterator<_Iterator>&, const
std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:341:5: note: template<class
_IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_IteratorL>&, const
std::reverse_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/stl_iterator.h:1049:5: note: template<class
_IteratorL, class _IteratorR> bool std::operator<(const std::move_iterator<_IteratorL>&, const
std::move_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/stl_iterator.h:1055:5: note: template bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/basic_string.h:2510:5: note: template<class
_CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const
std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2522:5: note: template<class
_CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT)
/usr/include/c++/4.6/bits/basic_string.h:2534:5: note: template<class
_CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) /usr/include/c++/4.6/bits/stl_vector.h:1290:5: note: template<class
_Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) /usr/include/c++/4.6/tuple:586:5: note: template<class ... _TElements,
class ... _UElements> bool std::operator<(const std::tuple<_TElements
...>&, const std::tuple<_Elements ...>&)
You are missing a typedef keyword for declaring an alias indicating the iterator category:
// Iterator traits - typedefs and types required to be STL compliant
//...
typedef std::forward_iterator_tag iterator_category;
~~~~~~^
Without the typedef, you are actually declaring a data member.
To avoid such mistakes, you can utilize the std::iterator class template as a base class, instead of defining those aliases on your own:
class GridIterator : public std::iterator<std::forward_iterator_tag
, typename GridT::Element>

using the find function from algorithm on vector

I want to use the find function from the algorithm library on a vector object. The vector object is a vector of customers, (Customer is a class I made). I first ran it and it gave me an error in stl_algo.h. I search the web for it and I searched here for it too, I found a question here about it and I ran the same code, but I still got that error.
My code is here:
Header File:
#include <string>
#include <sstream>
#include <map>
#include <vector>
using namespace std;
enum Status {ACTIVE, INACTIVE};
class Customer {
private:
// ID Database class for storing customers' ids
class IdDB {
private:
friend class Customer;
// member field
static map <string, int> idList;
// member function
static int getNumber (const string &threeLetters) {
map<string, int>::iterator i = idList.find(threeLetters);
if (i == idList.end()) {
idList.insert(pair <string, int> (threeLetters, 0));
return 0;
}else{
return ++(i->second);
}
}
};
string id;
string name;
string address;
Status status;
void makeId () {
string threeLetters = name.substr(0, 3);
int idNum = IdDB::getNumber(threeLetters);
stringstream oss;
oss << threeLetters << idNum;
id = oss.str();
}
public:
Customer (const string&, const string&, const Status);
// Accessor Methods
string &getId ();
string &getName ();
string &getAddress ();
Status getStatus ();
// Mutator Methods
void setAddress (const string&);
void setStatus (const Status);
// Misc. Methods
void printStatus ();
// Equality Operator Overloading
friend bool operator == (Customer&, Customer&);
};
class CustomerDB {
private:
static vector<Customer> customersList;
public:
static void addCustomer (const Customer&);
static void deleteCustomer (Customer&);
};
Source Code:
#include <iostream>
#include <string>
#include <algorithm>
#include "Customer.h"
using namespace std;
map<string, int> Customer::IdDB::idList;
Customer::Customer (const string &cName, const string &cAddress, const Status cStatus) : name(cName), address(cAddress), status(cStatus) {
makeId();
}
// Accessor Methods
string &Customer::getId () { return id; }
string &Customer::getName () { return name; }
string &Customer::getAddress () { return address; }
Status Customer::getStatus () { return status; }
// Mutator Methods
void Customer::setAddress (const string &newAddress) { address = newAddress; }
void Customer::setStatus (const Status newStatus) { status = newStatus; }
// Misc. Methods
void Customer::printStatus () {
if (status == ACTIVE)
cout << "Active";
else
cout << "In-Active";
}
vector<Customer> CustomerDB::customersList;
void CustomerDB::addCustomer (const Customer &customer) {
customersList.push_back(customer);
}
void CustomerDB::deleteCustomer (Customer &customer) {
vector<Customer>::iterator i;
i = find(customersList.begin(), customersList.end(), customer); // getting error in here
}
// Equality Operator Overloading
bool operator == (Customer &cust1, Customer &cust2) {
return cust1.getId() == cust2.getId();
}
after building with Code::Blocks, I got this,
in header file stl_algo.h:
}
/// This is an overload used by find() for the RAI case.
template<typename _RandomAccessIterator, typename _Tp>
_RandomAccessIterator
__find(_RandomAccessIterator __first, _RandomAccessIterator __last,
const _Tp& __val, random_access_iterator_tag)
{
typename iterator_traits<_RandomAccessIterator>::difference_type
__trip_count = (__last - __first) >> 2;
for (; __trip_count > 0; --__trip_count)
{
if (*__first == __val) // error in here exactly getting a red block
return __first;
++__first;
if (*__first == __val)
return __first;
++__first;
if (*__first == __val)
return __first;
Thanks
EDIT: Here is the build log
Compiling: C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/algorithm:63:0,
from C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp:5:
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h: In function '_RandomAccessIterator std::__find(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Customer*, std::vector<Customer> >, _Tp = Customer]':
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:4403:45: instantiated from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<Customer*, std::vector<Customer> >, _Tp = Customer]'
C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp:42:66: instantiated from here
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:162:4: error: no match for 'operator==' in '__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Customer*, _Container = std::vector<Customer>, __gnu_cxx::__normal_iterator<_Iterator, _Container>::reference = Customer&]() == __val'
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:162:4: note: candidates are:
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/postypes.h:218:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_pair.h:201:5: note: template<class _T1, class _T2> bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_iterator.h:285:5: note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_iterator.h:335:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/allocator.h:122:5: note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_T1>&, const std::allocator<_T2>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/allocator.h:127:5: note: template<class _Tp> bool std::operator==(const std::allocator<_Tp1>&, const std::allocator<_Tp1>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2427:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2434:5: note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2448:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2460:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/streambuf_iterator.h:194:5: note: template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_tree.h:309:5: note: template<class _Val> bool std::operator==(const std::_Rb_tree_iterator<_Tp>&, const std::_Rb_tree_const_iterator<_Val>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_tree.h:846:5: note: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator==(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_map.h:877:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_multimap.h:795:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_vector.h:1273:5: note: template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp:46:6: note: bool operator==(Customer&, Customer&)
C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp:46:6: note: no known conversion for argument 2 from 'const Customer' to 'Customer&'
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:4403:45: instantiated from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<Customer*, std::vector<Customer> >, _Tp = Customer]'
C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp:42:66: instantiated from here
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:166:4: error: no match for 'operator==' in '__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Customer*, _Container = std::vector<Customer>, __gnu_cxx::__normal_iterator<_Iterator, _Container>::reference = Customer&]() == __val'
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:166:4: note: candidates are:
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/postypes.h:218:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_pair.h:201:5: note: template<class _T1, class _T2> bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_iterator.h:285:5: note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_iterator.h:335:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/allocator.h:122:5: note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_T1>&, const std::allocator<_T2>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/allocator.h:127:5: note: template<class _Tp> bool std::operator==(const std::allocator<_Tp1>&, const std::allocator<_Tp1>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2427:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2434:5: note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2448:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2460:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/streambuf_iterator.h:194:5: note: template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_tree.h:309:5: note: template<class _Val> bool std::operator==(const std::_Rb_tree_iterator<_Tp>&, const std::_Rb_tree_const_iterator<_Val>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_tree.h:846:5: note: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator==(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_map.h:877:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_multimap.h:795:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_vector.h:1273:5: note: template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp:46:6: note: bool operator==(Customer&, Customer&)
C:\Users\KiKo-SaMa\Desktop\C++\DVD_App\Customer.cpp:46:6: note: no known conversion for argument 2 from 'const Customer' to 'Customer&'
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:170:4: error: no match for 'operator==' in '__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Customer*, _Container = std::vector<Customer>, __gnu_cxx::__normal_iterator<_Iterator, _Container>::reference = Customer&]() == __val'
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:170:4: note: candidates are:
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/postypes.h:218:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_pair.h:201:5: note: template<class _T1, class _T2> bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_iterator.h:285:5: note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_iterator.h:335:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/allocator.h:122:5: note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_T1>&, const std::allocator<_T2>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/allocator.h:127:5: note: template<class _Tp> bool std::operator==(const std::allocator<_Tp1>&, const std::allocator<_Tp1>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2427:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h:2434:5: note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
Process terminated with status 1 (0 minutes, 1 seconds)
50 errors, 0 warnings
You should work on your const correctness, the problem is that your equality comparator takes the arguments by non const reference, but the last argument to find is taken by const reference, which means that the compiler cannot use it there.
Incidentally, once you add the const there you will be forced to add const accessors to the data. Also, if your operator only uses the public interface there is no need to declare it as a friend
CodeBlocks may give errors about the stl files however they are not actually the errors. It shows the related stl file of your error.

Strange compiler error when counting letters

i made a progra which sum the occurences of a letter in a string , but i get a strange error, which i can't understand.
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int sum=0;
string sir;
vector<int> num;
vector<std::string> letters{"a","b","c","d","e","f","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
getline(cin,sir);
for(int i = 0; i < letters.size(); i++) {
sum = std::count(sir.begin(),sir.end(), letters[i]);
num.push_back(sum);
sum=0;
}
return 0;
}
and here ar the errors :
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_algo.h||In function 'typename std::iterator_traits<_InputIterator>::difference_type std::count(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >, _Tp = std::basic_string<char>, typename std::iterator_traits<_InputIterator>::difference_type = int]':|
E:\c\Watermelon\main.cpp:15|58|instantiated from here|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_algo.h|4591|error: no match for 'operator==' in '__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = char*, _Container = std::basic_string<char>, __gnu_cxx::__normal_iterator<_Iterator, _Container>::reference = char&]() == __value'|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_algo.h|4591|note: candidates are:|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\functional|2233|note: template<class _Res, class ... _Args> bool std::operator==(std::nullptr_t, const std::function<_Res(_ArgTypes ...)>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\functional|2227|note: template<class _Res, class ... _Args> bool std::operator==(const std::function<_Res(_ArgTypes ...)>&, std::nullptr_t)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\tuple|575|note: template<class ... _TElements, class ... _UElements> bool std::operator==(const std::tuple<_TElements ...>&, const std::tuple<_Elements ...>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|5322|note: template<class _RealType> bool std::operator==(const std::piecewise_linear_distribution<_RealType>&, const std::piecewise_linear_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|5080|note: template<class _RealType> bool std::operator==(const std::piecewise_constant_distribution<_RealType>&, const std::piecewise_constant_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|4841|note: template<class _IntType> bool std::operator==(const std::discrete_distribution<_IntType>&, const std::discrete_distribution<_IntType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|4609|note: template<class _RealType> bool std::operator==(const std::extreme_value_distribution<_RealType>&, const std::extreme_value_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|4434|note: template<class _RealType> bool std::operator==(const std::weibull_distribution<_RealType>&, const std::weibull_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|4259|note: template<class _RealType> bool std::operator==(const std::exponential_distribution<_RealType>&, const std::exponential_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|2459|note: template<class _RealType1> bool std::operator==(const std::gamma_distribution<_RealType>&, const std::gamma_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|3715|note: template<class _IntType> bool std::operator==(const std::geometric_distribution<_IntType>&, const std::geometric_distribution<_IntType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.tcc|1684|note: template<class _RealType1> bool std::operator==(const std::normal_distribution<_RealType>&, const std::normal_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|3337|note: bool std::operator==(const std::bernoulli_distribution&, const std::bernoulli_distribution&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|3337|note: no known conversion for argument 1 from 'char' to 'const std::bernoulli_distribution&'|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|2798|note: template<class _RealType> bool std::operator==(const std::cauchy_distribution<_RealType>&, const std::cauchy_distribution<_RealType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|1906|note: template<class _IntType> bool std::operator==(const std::uniform_real_distribution<_IntType>&, const std::uniform_real_distribution<_IntType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\random.h|1725|note: template<class _IntType> bool std::operator==(const std::uniform_int_distribution<_IntType>&, const std::uniform_int_distribution<_IntType>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_vector.h|1273|note: template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\streambuf_iterator.h|194|note: template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\basic_string.h|2460|note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\basic_string.h|2448|note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\basic_string.h|2434|note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\basic_string.h|2427|note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\allocator.h|127|note: template<class _Tp> bool std::operator==(const std::allocator<_Tp1>&, const std::allocator<_Tp1>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\allocator.h|122|note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_T1>&, const std::allocator<_T2>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_iterator.h|1031|note: template<class _Iterator> bool std::operator==(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_iterator.h|1025|note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_iterator.h|335|note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_iterator.h|285|note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_pair.h|201|note: template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\postypes.h|218|note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\ext\new_allocator.h|123|note: template<class _Tp> bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator<_Tp>&, const __gnu_cxx::new_allocator<_Tp>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_iterator.h|805|note: template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\bits\stl_iterator.h|799|note: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)|
||=== Build finished: 36 errors, 0 warnings ===|
value_type of sir is char, but letters[i] is std::string. You can't compare a string with a char. Try the following instead:
vector<char> letters{'a','b','c','d','e','f','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
I guess this is a homework excersise.
You are marking it rather complicated. Try the following
Create an array of length 26, initialise all values to zero.
Get the line.
Take each character in turn. Make it lower case. Check if between a-z. Convert a->0, b->1 etc
Increment the corresponding integer in the array created in 1
You can then print out the array with the corresponding number of letters found in the line.

C++ wait problem

I have a code like this
if (pid > 0) {
// Child
} else {
// Parent
}
while (wait() > 0) {}
And there are includes
#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <ctime>
#include <sys/types.h>
But when i try to compiile it with g++ (g++ test.cpp -o test) a have an errors:
lab3.cpp: In function «int main(int, char**)»:
lab3.cpp:57:18: error: no match for «operator>» in «{0} > 0»
lab3.cpp:57:18: warning: candidates are:
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/stl_pair.h:220:67: замечание: template<class _T1, class _T2> bool std::operator>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/stl_iterator.h:304:46: замечание: template<class _Iterator> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/stl_iterator.h:354:47: замечание: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/basic_string.h:2548:58: замечание: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/basic_string.h:2560:27: замечание: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/basic_string.h:2572:58: замечание: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../../include/c++/4.6.0/bits/stl_vector.h:1303:77: замечание: template<class _Tp, class _Alloc> bool std::operator>(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
What i'm doing wrong?
Your includes pull /usr/include/bits/waitstatus.h indirectly, which defines a union wait. Since you don't have a declaration of the wait-function, C++ sees wait() as a constructor expression. This means wait()>0 calls for an operator>(const wait &,int) which does not exist of course. GCC's diagnostics aren't really helpful here. Add sys/wait.h to fetch a valid prototype for the wait function.
wait() is defined in sys/wait.h.
But there's probably something else going on there that we can't see with the code you posted.
Try changing that to:
while (::wait() > 0) ...
to make sure you're calling the wait() function from the global namespace and not some other class or construct imported from elsewhere.

Concatenating const_string's

How do I concatenate two const_string's? Its home http://conststring.sourceforge.net/ says citation:
It also uses expression templates for concatenation, effectively eliminating overhead resulting from creation intermediate temporary objects.
So I thought its simplest form
typedef class boost::const_string<char> csc;
csc a, b;
csc c = a+b;
should work. But gcc-4.6 complains about operator+. Why? Do I have to cast a and b to std::string?
Error output follows:
semnet/realfile.cpp:185:13: error: no match for ‘operator+’ in ‘a + b’
semnet/realfile.cpp:185:13: note: candidates are:
/usr/include/c++/4.6/bits/stl_bvector.h:352:3: note: std::_Bit_const_iterator std::operator+(std::ptrdiff_t, const std::_Bit_const_iterator&)
/usr/include/c++/4.6/bits/stl_bvector.h:352:3: note: no known conversion for argument 1 from ‘csc’ to ‘std::ptrdiff_t’
/usr/include/c++/4.6/bits/stl_bvector.h:266:3: note: std::_Bit_iterator std::operator+(std::ptrdiff_t, const std::_Bit_iterator&)
/usr/include/c++/4.6/bits/stl_bvector.h:266:3: note: no known conversion for argument 1 from ‘csc’ to ‘std::ptrdiff_t’
/usr/include/c++/4.6/bits/basic_string.h:2414:20: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)
/usr/include/c++/4.6/bits/basic_string.h:2408:27: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)
/usr/include/c++/4.6/bits/basic_string.h:2402:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2396:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2384:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2378:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2372:58: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2359:79: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
/usr/include/c++/4.6/bits/basic_string.h:2344:26: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/include/c++/4.6/bits/basic_string.tcc:710:79: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.tcc:695:58: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2307:58: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/stl_iterator.h:1113:43: note: template<class _Iterator> std::move_iterator<_Iterator> std::operator+(typename std::move_iterator<_Iterator>::difference_type, const std::move_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:328:46: note: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:897:64: note: template<class _Iterator, class _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::operator+(typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
semnet/realfile.cpp:186:63: error: no match for ‘operator+’ in ‘xns + boost::const_string<char>(boost::cref [with T = const char*]((* & chashid_get_name_static(hid))), 4294967295u)’
semnet/realfile.cpp:186:63: note: candidates are:
/usr/include/c++/4.6/bits/stl_bvector.h:352:3: note: std::_Bit_const_iterator std::operator+(std::ptrdiff_t, const std::_Bit_const_iterator&)
/usr/include/c++/4.6/bits/stl_bvector.h:352:3: note: no known conversion for argument 1 from ‘const csc’ to ‘std::ptrdiff_t’
/usr/include/c++/4.6/bits/stl_bvector.h:266:3: note: std::_Bit_iterator std::operator+(std::ptrdiff_t, const std::_Bit_iterator&)
/usr/include/c++/4.6/bits/stl_bvector.h:266:3: note: no known conversion for argument 1 from ‘const csc’ to ‘std::ptrdiff_t’
/usr/include/c++/4.6/bits/basic_string.h:2414:20: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)
/usr/include/c++/4.6/bits/basic_string.h:2408:27: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)
/usr/include/c++/4.6/bits/basic_string.h:2402:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2396:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2384:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2378:53: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>&&)
/usr/include/c++/4.6/bits/basic_string.h:2372:58: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2359:79: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
/usr/include/c++/4.6/bits/basic_string.h:2344:26: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/include/c++/4.6/bits/basic_string.tcc:710:79: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.tcc:695:58: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2307:58: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/stl_iterator.h:1113:43: note: template<class _Iterator> std::move_iterator<_Iterator> std::operator+(typename std::move_iterator<_Iterator>::difference_type, const std::move_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:328:46: note: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:897:64: note: template<class _Iterator, class _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::operator+(typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
semnet/realfile.cpp:187:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [semnet/realfile.o] Fel 1
Compilation exited abnormally with code 2 at Fri Apr 29 15:42:00
Did you include the relevant header, boost/const_string/concatenation.hpp?
The const_string class contains a constructor for concatenations:
template<class T, class U>
const_string(concatenation<const_string, T, U> const& expr) // throw(std::bad_alloc, std::length_error)
: storage_type(0, expr.size())
{
expr.copy_result_to(const_cast<char_type*>(this->begin()));
}
and the library itself contains a concatenation class that takes two const_strings.
You could use those.
The header in which the concatenation class is defined is also where operator+ is defined, btw.