https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94062

            Bug ID: 94062
           Summary: Cannot construct tuple from convertible types
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.cencora at gmail dot com
  Target Milestone: ---

Following code does not compile on any gcc version that supports C++17
standard.
It compiles fine on clang.

While the static asserts pass, we get compilation error on tuple construction.
According to latest C++ draft constraints for this constructor are satisifed,
so it should compile.

template<class... UTypes> constexpr explicit(see below) tuple(UTypes&&... u);
Constraints: sizeof...(Types) equals sizeof...(UTypes) and sizeof...(Types)≥1
and is_­constructible_­v<Ti, Ui> is true for all i.


#include <type_traits>
#include <tuple>

struct Bar1
{
    Bar1(const Bar1&) = delete;
    Bar1(Bar1&&) = delete;
};

struct Bar2
{
    Bar2(const Bar2&) = delete;
    Bar2(Bar2&&) = delete;
};

struct Foo1
{
    operator Bar1() const;
};

struct Foo2
{
    operator Bar2() const;
};

int main()
{
    static_assert(std::is_constructible<Bar1, const Foo1&>::value, "");
    static_assert(std::is_constructible<Bar2, const Foo2&>::value, "");

    std::tuple<Bar1, Bar2> tup{Foo1{}, Foo2{}};
}

Reply via email to