Bug ID: 44540
           Summary: Inheriting from vector of move-only type leads to copy
                    constructor being used
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++

The following code does not compile with clang + libstdc++:

#include <vector>

struct MoveOnly
        MoveOnly() = default;
        MoveOnly(MoveOnly const &) = delete;
        MoveOnly(MoveOnly &&) = default;
        MoveOnly & operator=(MoveOnly const &) = delete;
        MoveOnly & operator=(MoveOnly &&) = default;

template <typename T>
class V : public std::vector<T>
        using std::vector<T>::vector;

        explicit V(std::vector<T> const & v) : std::vector<T>(v) {}

        explicit V(std::vector<T> && v) : std::vector<T>(std::move(v)) {}

void f()
        V<MoveOnly> v{};

It does however compile with gcc and also with clang + libc++.  (But then again
not with MSVC.)

I think there's no reason for the copy constructor to be used here though.

See also

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to