Hi,

Sorry, your code compiles and links (why sorry then :-)

However, my code compiles and links with -DBOOST_NO_INCLASS_MEMBER_INITIALIZATION.

We will look into it (I'd like to understand it).

Anyway, thank you very much!

Dirk Griffioen


-----Original Message-----
From: Aleksey Gurtovoy [mailto:agurtovoy@meta-comm.com]
Sent: woensdag 24 september 2003 19:51
To: Boost mailing list
Subject: Re: [boost] my code -> utility -> type_traits -> mpl -> ERROR


RE: [boost] my code -> utility -> type_traits -> mpl -> ERRORDirk Griffioen
wrote:
> Thanks!
>
> The code compiles & links fine both with a Jamfile (vacpp-tools) and
> a Makefile (my own defs.mak) on our AIX 433 with xlc 6 (the xlC_r
> variant)
>
> The problem was - sorry  & of course - something else (lexical_cast
> and not utility):
>
> //x.hpp
> template<class T>
> inline void DataType<T>::SetValue(const std::string& _value)
> {
>   value_ = boost::lexical_cast<T>(_value);
> }
>
> which in lexical_cast passes
>
>             bool operator>>(InputStreamable &output)
>             {
>                 return !is_pointer<InputStreamable>::value &&
>                        stream >> output &&
>                        (stream >> std::ws).eof();
>             }
>
> is_pointer (macro in is_pointer.hpp)  in turn becomes:
>
> template< typename T > struct is_pointer
> : mpl::bool_< ::boost::detail::is_pointer_impl<T>::value >
>
> where in our code  ::boost::detail::is_pointer_impl<T> evaluates to 0
because  ???
>
> (the linker has "ERROR: Undefined symbol: boost::mpl::bool_<0>::value")
>

So, basically, this one should fail to link then:

    template< bool C_ > struct bool_
    {
        static bool const value = C_;
    };

    template< bool C_ > bool const bool_<C_>::value; // !!!

    template< typename T > struct is_const : bool_<false> {};
    template< typename T > struct is_const<T const> : bool_<true> {};

    int main()
    {
        return is_const<int>::value;
    }

Does it?


> If I add a specialization for int the linker still complains (std::string
> is ok because of the different overload).
>
> I do not understand - but this turns into a template/type_traits question;

If you want a quick fix, I would suggest you to define
BOOST_NO_INCLASS_MEMBER_INITIALIZATION and see if it works that way.

Aleksey
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost