UTypes.fail.cpp revision dc1345fd4446b30f70a80c25db923ac09f14ade7
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 25class MoveOnly 26{ 27 MoveOnly(const MoveOnly&); 28 MoveOnly& operator=(const MoveOnly&); 29 30 int data_; 31public: 32 explicit MoveOnly(int data = 1) : data_(data) {} 33 MoveOnly(MoveOnly&& x) 34 : data_(x.data_) {x.data_ = 0;} 35 MoveOnly& operator=(MoveOnly&& x) 36 {data_ = x.data_; x.data_ = 0; return *this;} 37 38 int get() const {return data_;} 39 40 bool operator==(const MoveOnly& x) const {return data_ == x.data_;} 41 bool operator< (const MoveOnly& x) const {return data_ < x.data_;} 42}; 43 44int main() 45{ 46 { 47 std::tuple<MoveOnly> t = 1; 48 } 49} 50