On 2014-08-03 15:56, pfultz2 wrote:
Could you post an example? Is the concept check done in the return type as with enable_if? In C++11, we can use a default template parameter, rather than the return type, which is what the `CONCEPT_REQUIRES_` uses. So for example, we can write:
template
())> auto foo(T&&... xs) { ... } This works as long as all the varidiac template types are to be deduced by the compiler.
Thanks for the explanation. Good to know!
For classes this won't work:
// ERROR template
())> struct foo { ... }; Because you can't have a default template parameter after the varidiac template parameters in this context(you can when using speczializations).
Of course, you can't use `CONCEPT_REQUIRES_` for class specialization. In my library, I do provide a `TICK_CLASS_REQUIRES` which can be used for class specializations. Note that since it relies on `enable_if` it won't resolve ambiguities like Concepts Lite will. For example:
template<typename T> struct foo;
template<typename T> struct foo
())> { ... }; // Here we have to add a check for `RandomAccessIterator` to avoid ambiguities template<typename T> struct foo () && !RandomAccessIterator<T>())> { ... }; Perhaps, there is a way to this using tag dispatching, I'm not sure.
Thanks and regards, Roland