In C ++, temporary values ββcannot be bound to non-constant references.
Your function bucket_string substr(iterator start, iterator end) returns a temporary one, and your constructor / assignment operator accepts a non-constant reference as a parameter, hence your problem.
Thus, you need to add the missing const specifier to your constructor and assignment operator. For instance:
bucket_string(const bucket_string& rhs); bucket_string& operator=(const bucket_string& rhs);
Here is an interesting discussion on the topic for a better understanding.
On the side of the note, and if C ++ 11 is an option, you can also make your class movable. This will transfer the internal resources of your temporary object to another instance. We do not have enough context to say whether this is good in your situation.
Then you will have to implement these methods:
bucket_string(bucket_string&& other); bucket_string& operator=(bucket_string&& other);
source share