|
Boost : |
From: Pavol Droba (droba_at_[hidden])
Date: 2004-03-12 06:48:45
On Fri, Mar 12, 2004 at 11:55:22AM +0100, Toon Knapen wrote:
> First of all, the std::string of VisualAge is compatible with the
> standard (It seems like vacpp uses the Dinkum library BTW).
I see.
> So why algorithm/string/replace fails is a mystery to me. I tried to
> understand the code to see what't wrong but I don't really grasp the
> details of the implementation. For instance, where is
> 'has_native_replace_tester' defined ?
Testers are defined in spearate headers, in boost/algorithm/string/stl
directory. The reason for this it that there it a need to include the particular
stl header before tester. So if a user chooses not to include whole stl,
she can include only those testers that are needed.
Implementation is using testers as a workaround for compilers without
partial specialization. Current implementaion is no restrictive in any way,
therefore it is used as a default even form more compliant compilers.
This technique is called "Poor man's partial specialization"
> As a side remark, I wonder if declaring BOOST_STATIC_CONSTANT( bool, ...
> ) is legal C++. Paragraph 5.19.1 of the standard only talks about
> integral types and enums. However I did a small test like this
>
>
> -------------------
> Class A
> {
> Public:
> BOOST_STATIC_CONSTANT(bool, value = 3 ) ;
> } ;
>
> Int main()
> {
> itn v = A::value ;
> std::cout << v << std::endl ;
> return ;
> }
> --------------------
>
> And it compiles and gives the output '3' (although I would expect the
> boolean to int conversion to result in '1' instead of 3. But this is
> probably due to the 'enum-trick' in BOOST_STATIC_CONSTANT which might
> also be a cause for your test to fail.
>
Std 3.9.1.7 says, that bool is an integral type. But the problem can be
related to enum workaround. However, the examble you have provided seems ok.
Even if value==3, when used in a bool expression it should evaluate to "true".
And that is only thing I need.
Pavol.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk