SmartEngine  1.6.0
StrongNumber.h
1 // Copyright (C) Entropy Software LLC - All Rights Reserved
2 
3 #pragma once
4 
5 namespace SmartEngine
6 {
7 
8 template <class type, typename T> class StrongNumber
9 {
10 public:
12  : _value()
13  {
14  }
15 
16  StrongNumber(const T& value)
17  : _value(value)
18  {
19  }
20 
21  StrongNumber(T&& value) noexcept(std::is_nothrow_move_constructible<T>::value)
22  : _value(std::move(value))
23  {
24  }
25 
26  operator T&() noexcept { return _value; }
27 
28  operator const T&() const noexcept { return _value; }
29 
30  friend void swap(StrongNumber& a, StrongNumber& b) noexcept
31  {
32  using std::swap;
33  swap(static_cast<T&>(a), static_cast<T&>(b));
34  }
35 
36 private:
37  T _value;
38 };
39 
40 } // namespace SmartEngine
SmartEngine::StrongNumber
Definition: StrongNumber.h:9
SmartEngine::StrongNumber::StrongNumber
StrongNumber(T &&value) noexcept(std::is_nothrow_move_constructible< T >::value)
Definition: StrongNumber.h:21
SmartEngine::StrongNumber::swap
friend void swap(StrongNumber &a, StrongNumber &b) noexcept
Definition: StrongNumber.h:30
SmartEngine
Definition: A2CTrainer.h:10
SmartEngine::StrongNumber::StrongNumber
StrongNumber(const T &value)
Definition: StrongNumber.h:16
SmartEngine::StrongNumber::StrongNumber
StrongNumber()
Definition: StrongNumber.h:11