Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2003-04-05 22:02:12


Gennadiy Rozental wrote:
> > 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!!
>
> How come!? It should be very easy to prohibit all mutating operations for
> variant once it has top level const bound types (with static asserts)

Maybe I should take another approach:

  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

I don't see why there remains such difficulty. Perhaps if someone other than
Gennadiy could explain Gennadiy's argument to me we could make some
progress.

Thanks,
Eric


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk