template
struct list
{
template
list(Args...)
{
static_assert(sizeof...(Types)> 0);
}
};
template
list(Args...) -> list;
< br />int main()
{
list l{0, 0.1,'a'};
}
I hope decltype(l) is list< int ,double,char>. Unfortunately, g 7.2 and g trunk failed the static assertion. clang 5.0.0 and clang trunk compile and work as expected.
godbolt.org conformance view strong>
Is this a g bug? Or, why shouldn’t deduction guidelines be followed?
Adding the SFINAE constraint on the constructor seems to provide the desired behavior:
templatetypename = std::enable_if_t >
list(Args...)
{
static_assert(sizeof...( Types)> 0);
}
godbolt.org conformance view
template
list__f(Args... ); // constructor
template< br />list __f(Args... ); // deduction-guide
Both are valid (type… can be inferred to be empty in the first case ), but the call here should be vague-neither is more professional than the other. Type… does not participate in the ordering here (similar to the example in [temp.deduct.partial]/12). Therefore, the correct behavior is Enter the next decisive game, that is, favorites deduction-guides. Therefore, this should be a list
However, the behavior of gcc is to support constructors, so the static_assert trigger is because of the type …It is indeed empty in that case.
Please consider the following code:
template
struct list
{
template
list(Args...)
{
static_assert(sizeof...(Types)> 0);
}
};
template < typename... Args>
list(Args...) -> list;
int main()
{
list l {0, 0.1,'a'};
}
I want decltype(l) to be list
godbolt.org conformance view
Is this a g bug? Or, why shouldn’t deduction guidelines be followed?
Adding the SFINAE constraint on the constructor seems to provide the desired behavior:
templatetypename = std::enable_if_t >
list(Args...)
{
static_assert(sizeof...( Types)> 0);
}
godbolt.org conformance view
This is gcc bug 80871. The problem is that we finally got this set of candidates for deduction:
template< br />list __f(Args... ); // constructor
template
list__f( Args... ); // deduction-guide
Both are valid (type… can be inferred to be empty in the first case), but the call here should be ambiguous-both No more professional than the other. Type…do not participate in the ordering here (similar to the example in [temp.deduct.partial]/12). Therefore, the correct behavior is to enter the next tiebreaker, which is the favorites deduction-guides. Therefore, this should be a list
However, gcc’s behavior is to support constructors, so the static_assert trigger is really empty because of the type… in that case.
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2172 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC