64 class conditional_container<true, T>
67 conditional_container() { }
68 conditional_container(
const T &t) : value_(t) {}
70 conditional_container(
const conditional_container<true, T> & other) : value_(other.value_) {}
71 conditional_container(
const conditional_container<false, T> & other);
73 void operator= (
const T & t) { value_ = t; }
74 void operator= (T && t) { value_ = std::move(t); }
76 void operator= (
const conditional_container<true, T> & other) { value_ = other.value(); }
77 void operator= (
const conditional_container<false, T> & other);
79 T & value () {
return value_; }
80 const T & value ()
const {
return value_; }
82 static inline bool isValue () {
return true; }
88 class conditional_container<false, T>
91 conditional_container() { value_ = NEW T(); }
92 conditional_container(
const T & t) : value_(
nullptr) { value_ = NEW T(t); }
93 conditional_container(T && t) : value_(
nullptr) { value_ = NEW T(std::move(t)); }
95 conditional_container(
const conditional_container<true, T> & other) { value_ = NEW T(other.value()); }
96 conditional_container(
const conditional_container<false, T> & other) { value_ = NEW T(other.value()); }
97 conditional_container(conditional_container<false, T> && other)
99 value_ = other.value_;
100 other.value_ =
nullptr;
103 ~conditional_container() {
if ( value_ !=
nullptr ) {
delete value_; } }
105 void operator= (
const T & t) { *value_ = t; }
106 void operator= (T && t) { *value_ = std::move(t); }
108 void operator= (
const conditional_container<true, T> & other) { *value_ = other.value(); }
109 void operator= (
const conditional_container<false, T> & other) { *value_ = other.value(); }
110 void operator= (conditional_container<false, T> && other)
113 value_ = other.value_;
117 T & value () {
return *value_; }
118 const T & value ()
const {
return *value_; }
120 static inline bool isValue () {
return false; }
129 void conditional_container<true, T>::operator= (
const conditional_container<false, T> & other) { value_ = other.template conditional_container<false, T>::value(); }