
On Fri, Nov 6, 2009 at 1:17 PM, Emil Dotchevski <emildotchevski@gmail.com> wrote:
On Fri, Nov 6, 2009 at 9:44 AM, Zachary Turner <divisortheory@gmail.com> wrote:
Is there anything that can be done to improve the error messages generated by the compiler when a copy fails to be made due to a boost::noncopyable?
Easy cure is to spell out the private declarations for the copy constructor and the assignment operator "by hand". We all know that this spells "non-copyable".
Because of C++0x deleted functions, the idiom for noncopyable is going to change. class foo { foo( const foo & ) = delete; foo & operator =( const foo & ) = delete; ... }; Maybe Boost should have a macro, say BOOST_NONCOPYABLE(T), that would generate the above for C++0x compilers, and the following for pre-C++0x compilers: class foo { foo( const foo & ); foo & operator =( const foo & ); ... }; What the user would actually write would be: class foo { BOOST_NONCOPYABLE(foo) ... }; Another approach would be for the user to write: class foo { foo( const foo & ) BOOST_DELETED_FUNC; foo & operator =( const foo & ) BOOST_DELETED_FUNC; ... }; For 0x it would generate =delete while for non-0x it would generate nothing. --Beman