|
Boost : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-09-24 12:51:26
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk