[libcxx-commits] [PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

Matheus Izvekov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 17 12:08:21 PST 2021


mizvekov added a comment.

Isolated example:

  template <class T, int=0> struct span {};
  
  auto make_span() {
    using T = int;
    return span<const T, 0>();
  }
  
  void WontCompile() {
    span<int> s1 = make_span();
  }

https://godbolt.org/z/rjd6Y6f9d

  testcc:9:13: error: no viable conversion from 'span<const T, [...]>' to 'span<int, [...]>'
    span<int> s1 = make_span();
              ^    ~~~~~~~~~~~
  test.cc:1:34: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'span<const T, 0>'
        (aka 'span<const int, 0>') to 'const span<int, 0> &' for 1st argument
  template <class T, int=0> struct span {};
                                   ^
  test.cc:1:34: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'span<const T, 0>'
        (aka 'span<const int, 0>') to 'span<int, 0> &&' for 1st argument
  template <class T, int=0> struct span {};


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110216/new/

https://reviews.llvm.org/D110216



More information about the libcxx-commits mailing list