Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2005-01-31 21:49:43


On Mon, 31 Jan 2005 11:05:19 +0300, Vladimir Prus wrote:

 
> I think it would make sense to call 'validate' for the single element from
> 'validate' for vector. That would solve you problem.
Only problem here, is I can't - since the single-element validator has two
checks in it. First to ensure the option has not been seen before, and
second to ensure that there is one and only one element in the
std::vector<std::basic_string<charT> > passed to it.

I don't know if you saw it, but i posted my idea, in fully working form (I
know it works, because I'm actively using it for my own code) here:

http://www.neuromancy.net/viewcvs/Mantra-I/include/mantra/core/typed_value.h?root=mantra&rev=1.1&view=auto

As I suggested, the single-element and multi-element variants both call a
common 'value parser' - which can be passed in or defaulted. This
separates the logic of how to store the value, and how to parse it. And
more complex parsers that I pass in (say, validate_range) can call the
default parser to get the value, and then do the checks necessary - and it
won't matter a whit whether one or many of them are being stored.

> There were no demand for that ;-)
Well, I had need for set<>, and there is no real reason that the major
single-element std containers should not be implemented by default, as a
matter of course.

> This is a workaround for compilers without partial template
> specialization. The generic version is defined as
>
> template<class T, class charT>
> void validate(boost::any& v,
> const std::vector< std::basic_string<charT> >& xs, T*,
> long)
>
> and specific version is
>
> template<class T, class charT>
> void validate(boost::any& v,
> const std::vector< std::basic_string<charT> >& xs,
> std::vector<T>*, int)

Fair enough, my code (that I pasted above) doesn't have this workaround,
however it would be brain-dead to put in.

> Request noted. I'll try to do something.
Thanks :)

-- 
PreZ :)
Founder. The Neuromancy Society (http://www.neuromancy.net)

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