Opened 13 years ago

#3948 new Bugs

Conflict between concept_check and shared_ptr

Reported by: m.champlon@… Owned by: jsiek
Milestone: Boost 1.43.0 Component: concept_check
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

Hello,

The following code compiled with MSVC 2005 or 2008 :

#include <boost/concept_check.hpp>

namespace boost
{
    template< typename T >
    class some_type
    {};

    template< typename T1, typename T2 >
    bool operator<( const some_type< T1 >&, const some_type< T2 >& );
}

class c {};

BOOST_CONCEPT_ASSERT((boost::LessThanComparable< c >));

Produces the following error :

1>C:\Users\Mat\Desktop\dev\include\boost/concept_check.hpp(242) : error C2784: 'bool boost::operator <(const boost::some_type<T> &,const boost::some_type<T2> &)' : could not deduce template argument for 'const boost::some_type<T> &' from 'c'
1>        ..\..\src\tests\turtle_test\concept_check_test.cpp(19) : see declaration of 'boost::operator <'
1>        C:\Users\Mat\Desktop\dev\include\boost/concept_check.hpp(241) : while compiling class template member function 'boost::LessThanComparable<TT>::~LessThanComparable(void)'
...

Changing the namespace from boost to anything else (for instance nm) produces the correct error output e.g. :

1>C:\Users\Mat\Desktop\dev\include\boost/concept_check.hpp(242) : error C2676: binary '<' : 'c' does not define this operator or a conversion to a type acceptable to the predefined operator
1>        C:\Users\Mat\Desktop\dev\include\boost/concept_check.hpp(241) : while compiling class template member function 'boost::LessThanComparable<TT>::~LessThanComparable(void)'
...

This use case is actually quite common because for instance in boost::shared_ptr there is such a construct, in the boost namespace of course. Therefore the following code exhibits the same problem :

#include <boost/concept_check.hpp>
#include <boost/shared_ptr.hpp>

class c {};

BOOST_CONCEPT_ASSERT((boost::LessThanComparable< c >));

Maybe enclosing the concept check code into another level of namespace would prove enough to protect from the lookup ?

Thank you !

Change History (0)

Note: See TracTickets for help on using tickets.