|
Boost : |
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2005-05-02 10:01:43
On May 2, 2005, at 8:42 AM, Stefan Slapeta wrote:
> Howard Hinnant wrote:
>
>> The error message is saying that
>> boost::operator >= (ptr_container_detail::reversible_ptr_container<
>> ... animal...>, ...)
>> is being instantiated.
>> If I were to guess, it would be some kind of concepts check.
>> ptr_container_detail::reversible_ptr_container does derive from
>> less_than_comparable.
>
> [...]
>
> Actually, it's instantiated here:
>
> bool operator<( const reversible_ptr_container& r ) const // nothrow
> {
> return std::lexicographical_compare( begin(), end(), r.begin(),
> r.end() );
> }
>
> which again is instantiated here:
>
> template <class T, class B = ::boost::detail::empty_base>
> struct less_than_comparable1 : B
> {
> friend bool operator>(const T& x, const T& y) { return y < x; }
> friend bool operator<=(const T& x, const T& y) { return !(y < x); }
> friend bool operator>=(const T& x, const T& y) { return !(x < y); }
> };
Inlined friend functions in class templates are instantiated when the
enclosing class template is instantiated whether or not the friend is
actually used:
14.5.3p5:
> -5- When a function is defined in a friend function declaration in a
> class template, the function is defined at each instantiation of the
> class template. The function is defined even if it is never used. The
> same restrictions on multiple declarations and definitions which apply
> to non-template function declarations and definitions also apply to
> these implicit definitions. [Note: if the function definition is
> ill-formed for a given specialization of the enclosing class template,
> the program is ill-formed even if the function is never used. ]
This behavior will most likely change for C++0X:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#329
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk