Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-02-21 14:12:40


AMDG

Olaf wrote:
>
> That's correct. If it contains a double the string value is empty.
>
>
>> The variant cannot contain a string that is not "NA"
>>
>> struct available
>> : public boost::static_visitor<bool>
>> {
>> bool operator()( const double&) const
>> {
>> return true;
>> }
>>
>> bool operator()( const string& lhs) const
>> {
>> assert(lhs == "NA");
>>
>> return false; //???
>> }
>> };
>>
>
> May this work? There is always a string - empty or holding "NA".
>

I don't quite understand. variant<double, string> holds either a double
or a string at any one time, never both. If the variant holds a double then
the overload of operator() for double will be called, if a string then
the overload
for string will be called instead.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net