Le 17/12/14 07:20, Vicente J. Botet Escriba a écrit :
Le 16/12/14 22:53, paul Fultz a écrit :
Ok, I think I understand what you are aksing for. This how I would approach the problem using Tick. It does require defining different traits to get there(I am not sure how it could be done all in one take). First, I would define `is_callable` that checks if a function is called with `T` and returns `U`:
TICK_TRAIT(is_callable) { template
auto requires_(F&& f, T&& t, U&&) -> tick::valid< decltype(returns<U>(f(std::forward<T>(t)))) >; }; Next I would write a trait that checks if the two types, `Wt` and `Wu`, are mapped like `W<T> -> W<U>` and that the function takes `T` and returns `U`:
template
struct is_mapped : std::false_type {}; template class W, class T, class U, class F> struct is_mapped
: is_callable {}; And then I would write the `is_functor` to call the `map` function and check that it returns a mapped type:
TICK_TRAIT(is_functor) { template
auto requires_(F&& f, Wt&& wt) -> tick::valid< decltype(returns ( map(f, std::forward<Wt>(wt)) )) >; }; Does that make sense? Is this what you are asking for?
No, this trait has two parameters F and Wt. I'm looking for a trait with a single parameter W, the type constructor. Maybe I'm looking for a thing that should not exists ;-)
This SO question presents the same context. http://stackoverflow.com/questions/23659382/specifying-a-concept-for-a-type-... HTH, Vicente