Boost logo

Boost :

From: jeremy siek (jsiek_at_[hidden])
Date: 2000-10-02 23:31:33


Another way to get a function instantiated is to use its address as a
template parameter for a static member. Not sure if this will work for
Borland... Here's the general idea:

...
struct random_access_iterator_helper
{
  ...

  typedef D (*constraint_function)(const T&, const T&);

  template <constraint_function Function>
  struct instantiate_function { };

  static instantiate_function<requires_difference_helper>
    require_diff_instance;
};

This is the mechanism for the CLASS_REQUIRES macro in
boost/pending/concept_checks.hpp.

David Abrahams writes:
> No, if it's a member function it doesn't get instantiated unless used.
> Inline friend functions get instantiated even if unused (but not on MSVC or
> GCC which are broken in this regard), and we're taking advantage of that.
> Maybe someone knows a concept checking technique which will work here
> without inducing overhead even for broken compilers?


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