|
Boost : |
From: Marat Khalili (0x8.0p15_at_[hidden])
Date: 2007-08-15 14:48:00
Iain Denniston wrote:
>> 1. Is it a generalization of the std::ios_base::flags approach?
>
> As I understand it std::ios_base::flags will accept any integer - valid
> or otherwise.
Here in standard library of cygwin gcc 3.4.4 it doesn't.
> My library would be used to prevent invalid integers being
> passed (though would require valid flags be members of a single enum).
> Obviously in the case of std::ios_base::flags it would require a rewrite
> so's the argument would be of type boost::flags<...>
Its argument is <CODE>std::ios_base::fmtflags</CODE> here.
>> 2. It'd be more convenient without <CODE>flags<foo>(...)</CODE>
>> conversion, wouldn't it?
>
> [...] if you're passing multiple
> flags the only way I could think of making it work would be to provide a
> constructor that accepts integers - which would defeat the purpose of
> the library.
Well, I also don't think it is possible with integers, but it is
possible with flags being not integers like above.
Alternatively, can you make it <CODE>flags(foo_1) | foo2</CODE> (with
<CODE>flags</CODE> being function) or <CODE>flags | foo_1 | foo2</CODE>?
By the way, why not perform left shift in flags constructor instead of enum?
>> 3. Can <CODE>flags<foo>(foo_1) | foo_2</CODE> be used as a compile-time
>> constant?
>
> I'm not sure I entirely understand what you are getting at here - what
> is it you want to do?
I want it to be usable as a template parameter or switch case. For
instance, <CODE>class_parametrized_with_iosflags<std::ios_base::dec |
std::ios_base::left></CODE> will not compile. What about
<CODE>class_parametrized_with_foo<flags<foo>(foo_1) | foo_2></CODE>?
With Best Regards,
Marat
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk