Could someone please tell me why this does not work? I was under the impression that C++ would automatically pass the reference of the return-by-value function result to the constructor, but it complains that no matching operator could be found.
class bucket_string {
        public:
            bucket_string();
            bucket_string(bucket_string & rhs);
            bucket_string & operator=(bucket_string & rhs);
            virtual ~bucket_string();
            bucket_string substr(iterator start, iterator end){
                        bucket_string b(str);
                        return b;
                    }
 };
bucket_string bs("the quick brown fox jumps over the lazy dog");
bucket_string bs1 = bs.substr(bs.begin(), bs.end());
returns the following error:
error: no matching function for call to ‘bucket_string::bucket_string(bucket_string)’
note: candidates are: bucket_string::bucket_string(bucket_string&)
      bucket_string::bucket_string()
 
     
     
     
     
    