>   typedef boost::variant<int const, std::string const> GlobalParameter;
>   GlobalParameter input_socket(12345);
>   input_socket = "test"; // no way to prevent this
>
>   // ...or if that doesn't convince you...
>   GlobalParameter new_input_socket("test");
>   input_socket = new_input_socket; // no way to prevent this either
>
Let's return to the very begining of this thread:
http://aspn.activestate.com/ASPN/Mail/Message/1593371

Did I correctly undetand the reson why you think you could not revent above
assignment?

If yes, my proposition is to put following code in the assignment operator
( and all other mutating operators like copy assignment above):

BOOST_STATIC_ASSERT( !boost::is_const<T>::value );

That should prevent user from trying to use assignment operators for the
variant parameterized with const types.

Gennadiy.




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to