$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
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:
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.