Boost logo

Boost :

Subject: [boost] Tick: Trait instrospection library for C++14
From: paul Fultz (pfultz2_at_[hidden])
Date: 2014-05-22 12:23:22


Hi, I developed a trait introspection library for C++14 based on Eric Niebler's concept checking, here: https://github.com/pfultz2/Tick So you can build a simple `is_incrementable` trait like this:     TICK_TRAIT(is_incrementable)     {         template<class T>         auto requires(T&& x) -> TICK_VALID(             x++,             ++x         );     }; Then use it like this:     static_assert(is_incrementable<T>(), "Not incrementable"); Also, you can validate the return of an expressions like this:     TICK_TRAIT(is_equality_comparable)     {         template<class T, class U>         auto requires(T&& x, U&& y) -> TICK_VALID(             returns<bool>(x == y),             returns<bool>(x != y)         );     }; You can also match against another trait using placeholder expressions:     TICK_TRAIT(is_incrementable)     {         template<class T>         auto requires(T&& x) -> TICK_VALID(             return<std::is_integral<_>>(x++),             return<std::is_integral<_>>(++x)         );     }; Any feedback would be appreciated. Also, I don't knw if there would be any interest in incorporating this into boost. Thanks, Paul


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