[llvm-bugs] [Bug 40366] New: Failure to deduce template arguments for std::initializer_list aliases

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 17 11:23:02 PST 2019


            Bug ID: 40366
           Summary: Failure to deduce template arguments for
                    std::initializer_list aliases
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++'17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: davorin.ucakar at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Using an alias for std::initializer_list results in a failure to deduce
template arguments as in the following example (it compiles fine with GCC 8.2):

#include <initializer_list>

template <typename T>
using IL = std::initializer_list<T>;

template <typename T>
struct Foo {
  Foo(IL<T> list) {}

int main() {
  Foo foo{42}; // Error: no viable constructor or deduction guide
               // for deduction of template arguments of 'Foo'
  return 0;

However, the next deduction guide fixes the error:

template <typename T>
Foo(std::initializer_list<T>) -> Foo<T>;

The deduction guide doesn't work if we use IL<T> instead of

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190117/ec147d59/attachment-0001.html>

More information about the llvm-bugs mailing list