While reading P0589R0, I had the impression that
we are unable to define a concept for tuple-like types
I have tried and of course I have not reached.
http://melpon.org/wandbox/permlink/40vYx3K8tFtopwif
From the error report, it seems that there are no
short-cuts for operator && and ||.
I have also tried with "if constexpr" without
success. Can we use "if constexpr"inside
concept definitions?
Do you confirm that we are unable to define a TupleLike concept if we want to check for get<I>(tpl) for I in 0..std::tuple_size_v<T>-1?
If not, how we can define it?
Vicente
Le 26/02/2017 à 13:54, Vicente J. Botet Escriba a écrit :
While reading P0589R0, I had the impression that we are unable to define a concept for tuple-like types
I have tried and of course I have not reached.
http://melpon.org/wandbox/permlink/40vYx3K8tFtopwif
From the error report, it seems that there are no short-cuts for operator && and ||.
I have also tried with "if constexpr" without success. Can we use "if constexpr"inside concept definitions?
Do you confirm that we are unable to define a TupleLike concept if we want to check for get<I>(tpl) for I in 0..std::tuple_size_v<T>-1?
If not, how we can define it?
It seems that we can not use recursion while defining concepts. Without recursion, I don't see how we could define a TupleLike concept.
While reading P0589R0, I had the impression that we are unable to define a concept for tuple-like types
I have tried and of course I have not reached.
http://melpon.org/wandbox/permlink/40vYx3K8tFtopwif
From the error report, it seems that there are no short-cuts for operator && and ||.
I have also tried with "if constexpr" without success. Can we use "if constexpr"inside concept definitions?
Do you confirm that we are unable to define a TupleLike concept if we want to check for get<I>(tpl) for I in 0..std::tuple_size_v<T>-1?
If not, how we can define it?
It seems that we can not use recursion while defining concepts. Without recursion, I don't see how we could define a TupleLike concept.
You received this message because you are subscribed to the Google Groups "SG8 - Concepts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concepts+u...@isocpp.org.
To post to this group, send email to conc...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/concepts/.
Hmm, wait, we have clasic template meta-programming
With TMP, we can avoid unwanted evaluations and use recursion :)
While reading P0589R0, I had the impression that we are unable to define a concept for tuple-like types
I have tried and of course I have not reached.
http://melpon.org/wandbox/permlink/40vYx3K8tFtopwif
From the error report, it seems that there are no short-cuts for operator && and ||.
I have also tried with "if constexpr" without success. Can we use "if constexpr"inside concept definitions?
Do you confirm that we are unable to define a TupleLike concept if we want to check for get<I>(tpl) for I in 0..std::tuple_size_v<T>-1?
If not, how we can define it?
It seems that we can not use recursion while defining concepts. Without recursion, I don't see how we could define a TupleLike concept.
Allowing recursive concepts (and concept specialization) makes partial ordering undecidable. You can define the concept using a type trait.
But... since I wrote the tuple-for loop proposal, I had to think about this also. I would like to say that for a reasonable implementation of a tuple-like class and all integers N, the call get<N>(t) should be resolved. It may result in a static_assertion when called, but we should still be able to find a declaration.
I'm not sure that's reasonable. There are lots of things that an implementer may do with get<N>():- Use concepts to disable specializations for out-of-bounds N,- delete specializations for out-of-bounds N,- use return-type deduction.All of those will break the check.
This holds for element_type, too.
So, the only thing I can think to check is if tuple_size<> is specialized.
You could write the concept in way that:1. Checks for constexpr int N = tuple_size<T>,2. Evaluates a trait that attempts to resolve get<I>(t) for each I in [0, N).
The for-loop proposal just checks for tuple_size<T> and if any get<I>(t) fails during loop body instantiation, the program is ill-formed.
> It is weird that we wouldn't have a concept for the type supported by this tuple-based for loop, and that only the std::tuple_size is checked. In addition,
> I believe that the types supported should be any type supported by structured binding.
Why not for all the types supported by structure binding?