diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/common/bit_field.h | 6 | ||||
| -rw-r--r-- | src/common/make_unique.h | 16 | 
3 files changed, 22 insertions, 1 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 15989708d..3c3419bbc 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -49,6 +49,7 @@ set(HEADERS              logging/filter.h              logging/log.h              logging/backend.h +            make_unique.h              math_util.h              mem_arena.h              memory_util.h diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 9e02210f9..3ec061e63 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -142,7 +142,7 @@ public:      __forceinline BitField& operator=(T val)      { -        storage = (storage & ~GetMask()) | (((StorageType)val << position) & GetMask()); +        Assign(val);          return *this;      } @@ -151,6 +151,10 @@ public:          return Value();      } +    __forceinline void Assign(const T& value) { +        storage = (storage & ~GetMask()) | (((StorageType)value << position) & GetMask()); +    } +      __forceinline T Value() const      {          if (std::numeric_limits<T>::is_signed) diff --git a/src/common/make_unique.h b/src/common/make_unique.h new file mode 100644 index 000000000..2a7b76412 --- /dev/null +++ b/src/common/make_unique.h @@ -0,0 +1,16 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <memory> + +namespace Common { + +template <typename T, typename... Args> +std::unique_ptr<T> make_unique(Args&&... args) { +    return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); +} + +} // namespace  | 
