On 08/01/2014 08:22 AM, Robert Ramey wrote:
b) settlement of "best practice in the real world" of implementation of this idea. I recommended Boost Concept Check. Which isn't bad for a start, but isn't perfect either. I ideally I would like to see this used where its a good fit and an alternative for cases where it isn't.
Boost Concept Check is horribly dated and very limited, IMO. For my work
on a new range library[*], I built a new concept check library for
C++11. You define a concept like:
namespace concepts
{
struct BidirectionalIterator
: refines<ForwardIterator>
{
template<typename I>
auto requires_(I i) -> decltype(
concepts::valid_expr(
concepts::model_of<Derived>(
category_t<I>{},
std::bidirectional_iterator_tag{}),
concepts::has_type(--i),
concepts::has_type<I>(i--),
concepts::same_type(*i, *i--)
));
};
}
template<typename I>
using BidirectionalIterator =
concepts::modelsconcepts::BidirectionalIterator;
Then you can use it like a constexpr Boolean function in enable_if,
which can be conveniently wrapped in a simple macro like:
template