[libcxx-commits] [PATCH] D96523: [libc++] Rewrite the tuple constructors to be strictly Standards conforming

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 1 12:23:02 PDT 2021


ldionne added a comment.

I was trying to close the loop on this and got down to the following behaving differently in C++11/14 and C++17/20: https://godbolt.org/z/6x75njn7v

  #include <cstdio>
  
  template <class ...T>
  struct tuple {
    tuple() { }
    template <class ...U>
    tuple(tuple<U...>&&) { std::printf("construction\n"); }
  };
  
  struct Foo { };
  
  struct Derived : tuple<int> {
    template<class U>
    operator tuple<U>() && { std::printf("conversion\n"); return {}; }
  };
  
  int main(int, char**) {
    tuple<Foo> bar(Derived{});
  }

It looks like in C++11 and 14, we prefer the constructor, whereas in C++17 and above, we prefer the conversion. Both GCC and Clang have the same behavior. So I'm going to tweak the tests accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96523



More information about the libcxx-commits mailing list