|
Boost : |
Subject: Re: [boost] boost::noncopyable errors are difficult to diagnose on MSVC
From: Beman Dawes (bdawes_at_[hidden])
Date: 2009-11-06 17:13:17
On Fri, Nov 6, 2009 at 1:17 PM, Emil Dotchevski
<emildotchevski_at_[hidden]> wrote:
> On Fri, Nov 6, 2009 at 9:44 AM, Zachary Turner <divisortheory_at_[hidden]> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk