1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <tuple> 11 12 // template <class... Types> class tuple; 13 14 // template <class... UTypes> 15 // explicit tuple(UTypes&&... u); 16 17 /* 18 This is testing an extension whereby only Types having an explicit conversion 19 from UTypes are bound by the explicit tuple constructor. 20 */ 21 22 #include <tuple> 23 #include <cassert> 24 25 class MoveOnly 26 { 27 MoveOnly(const MoveOnly&); 28 MoveOnly& operator=(const MoveOnly&); 29 30 int data_; 31 public: MoveOnly(int data=1)32 explicit MoveOnly(int data = 1) : data_(data) {} MoveOnly(MoveOnly && x)33 MoveOnly(MoveOnly&& x) 34 : data_(x.data_) {x.data_ = 0;} operator =(MoveOnly && x)35 MoveOnly& operator=(MoveOnly&& x) 36 {data_ = x.data_; x.data_ = 0; return *this;} 37 get() const38 int get() const {return data_;} 39 operator ==(const MoveOnly & x) const40 bool operator==(const MoveOnly& x) const {return data_ == x.data_;} operator <(const MoveOnly & x) const41 bool operator< (const MoveOnly& x) const {return data_ < x.data_;} 42 }; 43 main()44int main() 45 { 46 { 47 std::tuple<MoveOnly> t = 1; 48 } 49 } 50