Boost logo

Boost Users :

From: Mattias Nissler (mattias.nissler_at_[hidden])
Date: 2007-11-02 11:38:55


Hi,

I've just recently started using boost::concept_check. It suits my needs
very well and works perfectly so far. However, today I've come across
something that is missing: The ConceptConcept! What I mean is a meta
concept that checks whether a given template is a concept checking class.
It should be relatively straightforward to implement, here is some example
code I've cooked up:

#include <boost/concept_check.hpp>

template<template<typename T> class _TConcept>
struct ConceptConcept
{
  /* Instead of int, any type allowed as template parameter should do. */
  _TConcept<int> c;

  void constraints()
  {
    /* Require the constraints() function to exist in _TConcept. */
    c.constraints();
  }
};

template<template<typename TX> class T>
void function()
{
  boost::function_requires< ConceptConcept<T> >();
}

template<typename T>
struct NoConcept
{
};

int main(void)
{
  function<boost::IntegerConcept>();
  //function<NoConcept>(); // <- fails, NoConcept::constraints() is missing.
}

Note that due to the template template technique, this only works for
ConceptConcept. Higher meta levels (e.g. ConceptConceptConcept) are not
supported by this code.

I'd like to see this in boost::concept_check. What do you think?

Cheers,

- Mattias


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net