Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2003-04-05 22:21:31

> 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:

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

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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at