From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-11 01:18:10
--- Douglas Gregor <gregod_at_[hidden]> wrote:
> I'm in the same camp as Dave here: I'm solidly against having a singular state
> in variant unless the user asks for it with boost::empty, but I'm not going
> to argue the issue further. You know variant best, and I'm sure you'll make
> the right decision.
Consider a team of programmers working on one project.
One of them has to implement a function f()
that accepts a variant as one of its parameters
f( variant<...>& v ).
If the variant interface says that the variant can
go 'singular' or 'unspecified content' in *some* cases,
The poor guy will have to handle it as a normal
normal variant's interface. He would not care when
and how the variant goes 'singular' or
'unspecified content'. If any of these can happen,
he should handle it in his f() function.
It is like f( char* p ). A good f() behaves well
when p = NULL.
I think that it would be much simpler for him to
deal with the variant parameter, when
it can go 'singular' than 'unspecified content'.
Here is an example.
Let's say I am team member who needs to
implement a function that handles user events.
f( variant<mouse_event, keyboar_event, menu_command>& v )
If I know that according to variant's spec the content of any
of these types (mouse_event, keyboard_event, menu_command)
can be unspecified (value-initialized) (*** I don't care why ***),
How in the world am I suppose to handle it in my function?
It is getting even worse if I want to release the function
f() as a public library.
On the other hand, if I know that 'v' can be in of
1. good data
I can easily catch it and say to the rest or my
team (or my users) "I am going to ignore singular variants"
or "I am to throw an exception, 2345"
I suggest to look at this problem from a practicle angle.
Besides singular variant is more basic.
One can always implement 'unspecified content'
variants using 'singular' variants.
Other way around is more complicated, you'd need
to append to user defined list of types some empty
types under the covers. Yack.
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk