boost::concept_check: ConceptConcept missing!
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
on Fri Nov 02 2007, Mattias Nissler <mattias.nissler-AT-gmx.de> wrote:
I'd like to see this in boost::concept_check. What do you think?
What is the practical use case? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
On Fri, 02 Nov 2007 23:20:42 -0400, David Abrahams wrote:
What is the practical use case?
Well, what I wanted to achieve is to make some class use not a fixed concept, but make it configurable. So I came up with a concept for this class that requires a concept check as a member template. Then, the class would use this concept check template from it's type parameters to concept-check some type parameters to a template member function. However, I've now arrived at a different solution, but I thought I'd bring this up here since I felt the meta concept would be an interesting thing to discuss. Mattias
participants (2)
-
David Abrahams
-
Mattias Nissler