
abir basak wrote:
abir basak wrote: To make the problem little clearer, typedef boost::circular_buffer<int> cbi; typedef std::vector<int> vi; This code works, boost::sub_range<vi> get_range(vi& v,int from,int to){ return boost::sub_range<vi>(v.begin()+from,v.begin()+to); } But this don't. boost::sub_range<cbi> get_range(cbi& v,int from,int to){ return boost::sub_range<cbi>(v.begin()+from,v.begin()+to); }
FWIW, under VC8, boost::sub_range is not always CopyConstructible. You can prefer boost::iterator_range instead. This behavior comes from the VC8 bug. (See: http://tinyurl.com/yb8ban) Put simply, her implicitly-defined copy-constructor/copy-assignment-operator is not conforming. IIRC, VC7.1 also has this bug under weird situation, but I'm not sure. The copy-assignment-operator of boost::sub_range(CVS Head) seems to be patched for that bug, but the copy-constructor seems not yet? -- Shunsuke Sogame