[range_ex] range_ex conflicts with non_copyable
Hi,
The following code works well with old version of range_ex (Dec 2008), but when I update range_ex to an newer version (after Feb 2009), the code cannot compile.
code:
#include
struct A : boost::noncopyable { int a; A(int _a) : a(_a) {} bool operator == (const A& r) const { return a == r.a; } };
int main() { boost::ptr_vector<A> pva; A a(0); std::find(pva.begin(), pva.end(), a); // ok boost::find(pva, a); // cause an error }
compiler: msvc2008
error message: e:\zxg\boost\range_ex\range.cpp(8) : error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(27) : see declaration of 'boost::noncopyable_::noncopyable::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable_::noncopyable' This diagnostic occurred in the compiler generated function 'A::A(const A &)'
What's the benefit of providing assignment operator but blocking the copy-constructor?
2009/4/5 Igor R
struct A : boost::noncopyable { int a; A(int _a) : a(_a) {} bool operator == (const A& r) const { return a == r.a; } };
int main() { boost::ptr_vector<A> pva; A a(0); std::find(pva.begin(), pva.end(), a); // ok boost::find(pva, a); // cause an error }
compiler: msvc2008
error message: e:\zxg\boost\range_ex\range.cpp(8) : error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(27) : see declaration of 'boost::noncopyable_::noncopyable::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable_::noncopyable' This diagnostic occurred in the compiler generated function 'A::A(const A &)'
What's the benefit of providing assignment operator but blocking the copy-constructor?
There is no assignment operator in the provided code snippet. Roman Perepelitsa.
041021042 skrev:
Hi,
The following code works well with old version of range_ex (Dec 2008), but when I update range_ex to an newer version (after Feb 2009), the code cannot compile.
code: #include
#include struct A : boost::noncopyable { int a; A(int _a) : a(_a) {} bool operator == (const A& r) const { return a == r.a; } };
int main() { boost::ptr_vector<A> pva; A a(0); std::find(pva.begin(), pva.end(), a); // ok boost::find(pva, a); // cause an error }
compiler: msvc2008
error message: e:\zxg\boost\range_ex\range.cpp(8) : error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(27) : see declaration of 'boost::noncopyable_::noncopyable::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable_::noncopyable' This diagnostic occurred in the compiler generated function 'A::A(const A &)'
Perhaps the argument of find() is taken by value? I guess we should use const T& here. -Thorsten
Hi, On Sun, Apr 5, 2009 at 9:52 PM, Thorsten Ottosen < thorsten.ottosen@dezide.com> wrote:
compiler: msvc2008
error message: e:\zxg\boost\range_ex\range.cpp(8) : error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(27) : see declaration of 'boost::noncopyable_::noncopyable::noncopyable' d:\software\boost_1_37_0\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable_::noncopyable' This diagnostic occurred in the compiler generated function 'A::A(const A &)'
Perhaps the argument of find() is taken by value? I guess we should use const T& here.
The second argument of find was mistakenly being taken by value. Please accept my apologies for this oversight. I have amended the code and placed an updated version in the vault. I shall be examining the code for similar errors, and extending the test harnesses shortly.
-Thorsten
Thank you for the defect report. Best wishes, Neil Groves
participants (5)
-
041021042
-
Igor R
-
Neil Groves
-
Roman Perepelitsa
-
Thorsten Ottosen