#include <iostream>
template <class... Ts>
struct Y
{
static_assert(sizeof...(Ts)>0, "!");
};
template <class... Ts>
std::ostream& operator<<(std::ostream& os, Y<Ts...> const& )
{
return os << std::endl;
}
int main()
{
}
template <class... Ts>
struct Y {};
template <class... Ts>
void f(Y<Ts...>) {}
int main() {
f({});
}
Basing this on "arguments [that] make them non-deduced" seems a bad
idea. The fact that in your and in the original example the parameter
is a non-deduced context is not representative for this problem at
large, I think. If "std::endl" had been an object or a non-overloaded
function, I would still not want "Y<Ts...>" make "Ts" fallback to be
empty. Why behave different for "Ts..." and "Ts" here?
I would perhaps say that, only if every appearance of Ts is in
non-deduced contexts or in parameters that don't participate in
deduction, it may fallback to being empty.
> email to std-discussion+unsubscribe@isocpp.org.
> To post to this group, send email to std-dis...@isocpp.org.
> Visit this group at
> https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
Basing this on "arguments [that] make them non-deduced" seems a bad
idea. The fact that in your and in the original example the parameter
is a non-deduced context is not representative for this problem at
large, I think. If "std::endl" had been an object or a non-overloaded
function, I would still not want "Y<Ts...>" make "Ts" fallback to be
empty. Why behave different for "Ts..." and "Ts" here?
And, we need to be careful in considering "f<>({})", which I suppose we should keep well-formed.
I would perhaps say that, only if every appearance of Ts is in non-deduced contexts or in parameters that don't participate in deduction, it may fallback to being empty.
template <typename... T>
void f(tuple<T...>);
f({}); // T... appears in a deduced "type" context in tuple<T...>, so you're saying this should fail
On Tuesday, November 22, 2016 at 10:12:08 PM UTC, Johannes Schaub wrote:And, we need to be careful in considering "f<>({})", which I suppose we should keep well-formed.Making f({}) and f<>({}) behave differently wrt to deduction is very unsound, IMO. I am currently drafting a paper on free packs and pack literals, under which you could write f<{}>(...) to express that the pack is empty. I would personally prefer that to f<>(...).On Tuesday, November 22, 2016 at 10:07:37 PM UTC, Johannes Schaub wrote:I would perhaps say that, only if every appearance of Ts is in non-deduced contexts or in parameters that don't participate in deduction, it may fallback to being empty.I think you have to be more careful with terminology, because as I interpret the above, you're saying that Barry's original example should fail--after all, std::endl as an argument is a non-deduced context as per [temp.deduct.type]/(5.5).If you meant that the function parameter type must already disallow any deduction for the pack right away, i.e. bullets 1, 2, 3, 4 and 7 in [temp.deduct.type]/5, then the condition appears to be inconsistent with [temp.deduct.call]/1, which mandates (via fallback to [temp.arg.explicit]/3--cf. Bogdan's comment here) that when the pack appears in a "proper" non deduced context, it is deduced as empty.
template <typename... T>
void f(tuple<T...>);
f({}); // T... appears in a deduced "type" context in tuple<T...>, so you're saying this should fail
On Tuesday, November 22, 2016 at 10:12:08 PM UTC, Johannes Schaub wrote:And, we need to be careful in considering "f<>({})", which I suppose we should keep well-formed.Making f({}) and f<>({}) behave differently wrt to deduction is very unsound, IMO. I am currently drafting a paper on free packs and pack literals, under which you could write f<{}>(...) to express that the pack is empty. I would personally prefer that to f<>(...).On Tuesday, November 22, 2016 at 10:07:37 PM UTC, Johannes Schaub wrote:I would perhaps say that, only if every appearance of Ts is in non-deduced contexts or in parameters that don't participate in deduction, it may fallback to being empty.I think you have to be more careful with terminology, because as I interpret the above, you're saying that Barry's original example should fail--after all, std::endl as an argument is a non-deduced context as per [temp.deduct.type]/(5.5).If you meant that the function parameter type must already disallow any deduction for the pack right away, i.e. bullets 1, 2, 3, 4 and 7 in [temp.deduct.type]/5, then the condition appears to be inconsistent with [temp.deduct.call]/1, which mandates (via fallback to [temp.arg.explicit]/3--cf. Bogdan's comment here) that when the pack appears in a "proper" non deduced context, it is deduced as empty.
template <typename... T>
void f(tuple<T...>);
f({}); // T... appears in a deduced "type" context in tuple<T...>, so you're saying this should failSo now your condition is breaking code. I probably misunderstood what you meant, could you elaborate?