fork(1) download
  1. #include <algorithm>
  2. #include <type_traits>
  3.  
  4. using namespace std;
  5.  
  6. template <typename Data>
  7. class Container
  8. {
  9. public:
  10. typedef Container<Data> self_type;
  11.  
  12. Container():
  13. m_data()
  14. {
  15. }
  16.  
  17. template <class D = Data>
  18. Container(const typename std::enable_if<std::is_copy_constructible<D>::value,
  19. self_type>::type& other_data) :
  20. m_data(other_data.m_data)
  21. {
  22. }
  23.  
  24. Container(self_type&& other)
  25. {
  26. std::swap(m_data, other.m_data);
  27. }
  28.  
  29. private:
  30. Data m_data;
  31. };
  32.  
  33. class SomeData
  34. {
  35. public:
  36. SomeData(){}
  37. SomeData(const SomeData&) = delete;
  38. };
  39.  
  40. int main()
  41. {
  42. Container<SomeData> container;
  43. return 0;
  44. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty