Changeset 11054 for code/branches/cpp11_v3/src/libraries/util/MultiType.h
- Timestamp:
- Jan 10, 2016, 1:54:11 PM (8 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/src/libraries/util/MultiType.h
r10197 r11054 175 175 public: 176 176 inline MT_ValueBase(void* data, Type::Enum type) : type_(type), bLastConversionSuccessful(true), data_(data) {} 177 inline virtual~MT_ValueBase() {}177 virtual inline ~MT_ValueBase() {} 178 178 179 179 virtual MT_ValueBase* clone() const = 0; … … 266 266 267 267 /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. 268 inline MultiType() : value_( 0) { }268 inline MultiType() : value_(nullptr) { } 269 269 /// Constructor: Assigns the given value and sets the type. 270 270 template <typename V> 271 inline MultiType(const V& value) : value_( 0) { this->set(value); }271 inline MultiType(const V& value) : value_(nullptr) { this->set(value); } 272 272 /// Copyconstructor: Assigns value and type of the other MultiType. 273 inline MultiType(const MultiType& other) : value_( 0) { this->set(other); }273 inline MultiType(const MultiType& other) : value_(nullptr) { this->set(other); } 274 274 275 275 /// Destructor: Deletes the MT_Value. … … 325 325 if (this->value_) 326 326 delete this->value_; 327 this->value_ = (other.value_) ? other.value_->clone() : 0;327 this->value_ = (other.value_) ? other.value_->clone() : nullptr; 328 328 } 329 329 … … 332 332 333 333 /// Resets value and type. Type will be void afterwards and null() returns true. 334 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }334 inline void reset() { if (this->value_) delete this->value_; this->value_ = nullptr; } 335 335 /// Resets the value and changes the internal type to T. 336 336 template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } … … 428 428 } 429 429 /// Creates a new value container (works only with specialized types). 430 template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; } 430 template <typename T> inline void createNewValueContainer(const T& value) 431 { 432 // If you reach this code, you used MultiType with an unsupported type T 433 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 434 } 431 435 432 436 MT_ValueBase* value_; //!< A pointer to the value container … … 486 490 template <> inline long double MultiType::get() const { return (this->value_ ? this->value_->get<long double>() : 0); } 487 491 template <> inline bool MultiType::get() const { return (this->value_ ? this->value_->get<bool>() : 0); } 488 template <> inline void* MultiType::get() const { return (this->value_ ? this->value_->get<void*>() : 0); }492 template <> inline void* MultiType::get() const { return (this->value_ ? this->value_->get<void*>() : nullptr); } 489 493 template <> inline std::string MultiType::get() const { return (this->value_ ? this->value_->get<std::string>() : NilValue<std::string>()); } 490 494 template <> inline orxonox::Vector2 MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Vector2>() : NilValue<orxonox::Vector2>()); }
Note: See TracChangeset
for help on using the changeset viewer.