Apparently I'm missing something obvious, most likely with SFINAE - but for the life of me I just can't find what "it" is. I could blame my wisdom tooth, but it would sound weird because it's about wisdom...
In C++ when using Concepts (Boost, Lite or whatever) one uses something like REQUIRES(list_of_concepts)
to enforce that eg.: a type in a function invocation follows a concept like "BidirectionalIteratorAccess
". But what is the corresponding "query" component for this feature? Essentially, how do I ask if a class type T models BidirectionalIteratorAccess
?
All I know is that I'm not looking for REQUIRES
or BOOST_CONCEPT_ASSERT
as they are true-or-compilation-error; I'm looking for something that is true-or-false, like the type_traits
. The documentation of Boost.Concept Assert and others suggest that one would use a SFINAE check with something like not_satisfied<Concept>
but if so I for some reason can't figure out which part goes where. I can only guess that a SFINAE test would end up like this:
template <typename T> struct models_MyConcept {
template <typename C>
static yes_t test (some_sort_of_argument_using_MyConcept);
template <typename C>
static no_t test (...);
static const bool value = sizeof(something_calling_test_with_a_C_argument_somehow) == sizeof(yes_t);
};
…What kind of idiot named them wisdom teeth anyway? And why was I digressing?
In Concepts Lite a constraint is a
constexpr bool
template function that returns true if and only if the template parameter(s) model the concept. SoBidirectionalIteratorAccess<T>()
would evaluate totrue
if and onlyT
modelsBidirectionalIteratorAccess
.I understand this answer is likely not useful to you, but you did say "Boost, Lite, or whatever."