$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Eric Friedman (ebf_at_[hidden])
Date: 2003-04-04 18:17:47
Gennadiy Rozental wrote:
> > > So what I want is
> > >
> > > typedef boost::variant<int const,std::string const> GlobalParameter;
> > >
> > > GlobalParameter input_socket( 12345 ); // localhost::12345
> > > GlobalParameter output_socket( "MultiplexorSocket" );
[snip]
>
> What if variant is the member of the class template, and we want to
> support const type arguments? Why not implement const support if it does
not
> cost us too much and you agree that there exist possible usage cases?
I argue that top-level const type arguments are meaningless in the context
of variant. Given the example you provide:
typedef boost::variant<int const, std::string const> GlobalParameter;
GlobalParameter input_socket(12345);
input_socket = 54321; // no way to prevent this!!
If there is no way to prevent the code above, then I see the allowance of
top-level const types as misleading, at best. Please help me understand your
view if you continue to disagree.
> But I feel more relaxed on this point now. Though I believe if variant
> will end up without const type support it should be clearly documented
that
> there is a way to implement variant constants in many cases.
We can put it in the docs, but it seems straightforward that a const variant
would, in fact, not allow modification. What reason would lead someone to
believe otherwise?
Thanks,
Eric