diff options
| author | Naios <naios-dev@live.de> | 2015-04-26 23:45:52 +0200 |
|---|---|---|
| committer | Naios <naios-dev@live.de> | 2015-04-26 23:45:52 +0200 |
| commit | 800d5d893964a82265577d3352d683035b589f78 (patch) | |
| tree | 7b68f59be62a5df207c158a3f70fbf5860b91f69 /src/server/shared | |
| parent | f4a4e5de3d7d89116bc6eda20c0d37361fdd2023 (diff) | |
Core/Misc: Replace tc's optional with boost::optional.
* benefits from empty optimization (objects are only constructed if needed).
* supports r-value references (move semantics) (boost >= 1.56.0).
* preparation for c++14/17's std::optional and std::none_t.
* add move constructor to CompactArray.
Diffstat (limited to 'src/server/shared')
| -rw-r--r-- | src/server/shared/Common.h | 6 | ||||
| -rw-r--r-- | src/server/shared/Utilities/Util.h | 21 |
2 files changed, 6 insertions, 21 deletions
diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h index 8a1ccf6029a..4e1e24cce42 100644 --- a/src/server/shared/Common.h +++ b/src/server/shared/Common.h @@ -39,6 +39,8 @@ #include <sstream> #include <algorithm> +#include <boost/optional.hpp> + #include "Debugging/Errors.h" #include "Threading/LockedQueue.h" @@ -157,4 +159,8 @@ struct LocalizedString #define MAX_QUERY_LEN 32*1024 +//! Optional helper class to wrap optional values within. +template <typename T> +using Optional = boost::optional<T>; + #endif diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index 9a8514ea5ca..0886b625370 100644 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -30,27 +30,6 @@ #include <stdarg.h> #include <cstring> -template<typename T> -struct Optional -{ - Optional() : Value(), HasValue(false) { } - - T Value; - bool HasValue; - - inline void Set(T const& v) - { - HasValue = true; - Value = v; - } - - inline void Clear() - { - HasValue = false; - Value = T(); - } -}; - // Searcher for map of structs template<typename T, class S> struct Finder { |
