Boost logo

Boost :

From: Nicola Musatti (Nicola.Musatti_at_[hidden])
Date: 2006-10-20 17:55:25


Hallo,
I was looking at the concept_check tests that fail for Borland and I
can't understand why they're expected to compile but not to link. If I
haven't made any mistake the following should be a stripped down version
of concept_check_fail_expected, which is marked as link_fail (the
comments are mine - feel free to correct me):

#include <boost/mpl/identity.hpp>

namespace boost {

// mpl::identity is used to ensure that the Concept argument is not
instantiated when function_requires is

template <class Concept>
inline void function_requires(mpl::identity<Concept>* = 0)
{

// this causes Concept::constraints to be instantiated -
// and nothing else

   void (Concept::*x)() = &Concept::constraints;
}

// This enforces the "convertible to bool" requirement

template <class TT>
   void require_boolean_expr(const TT& t) {
     bool x = t;
   }

   template <class TT>
   struct EqualityComparableConcept
   {

// Why shouldn't this just fail to compile due to operator== not being
// defined for foo?

     void constraints() {
       require_boolean_expr(a == b);
     }
     TT a, b;
   };

} // namespace boost

struct foo { };

int
main()
{
   boost::function_requires< boost::EqualityComparableConcept<foo> >();
   return 0;
}

What am I missing? Thanks for your help.

Cheers,
Nicola Musatti


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk