Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/benchmark
diff options
context:
space:
mode:
authorJoe Burzinski2019-11-18 22:22:38 -0600
committerMartin Hořeňovský2020-02-13 16:15:50 +0100
commit0fbf4f3e152e8fe9a41fa1a960ea3dac3cb76e59 (patch)
treed533f0a4066aab4cef66f4252d529454ab05a6cf /src/catch2/benchmark
parentad3f50bbc1ad66bf9ad5005d1a5f52eb6b28972f (diff)
downloadcatch3-0fbf4f3e152e8fe9a41fa1a960ea3dac3cb76e59.tar.gz
Fix wrong namespacing of benchmarking constructor helpers
Diffstat (limited to 'src/catch2/benchmark')
-rw-r--r--src/catch2/benchmark/catch_constructor.hpp110
1 files changed, 56 insertions, 54 deletions
diff --git a/src/catch2/benchmark/catch_constructor.hpp b/src/catch2/benchmark/catch_constructor.hpp
index bf6dfec9..f12958f3 100644
--- a/src/catch2/benchmark/catch_constructor.hpp
+++ b/src/catch2/benchmark/catch_constructor.hpp
@@ -14,60 +14,62 @@
#include <type_traits>
namespace Catch {
- namespace Detail {
- template <typename T, bool Destruct>
- struct ObjectStorage
- {
- using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
-
- ObjectStorage() : data() {}
-
- ObjectStorage(const ObjectStorage& other)
- {
- new(&data) T(other.stored_object());
- }
-
- ObjectStorage(ObjectStorage&& other)
- {
- new(&data) T(std::move(other.stored_object()));
- }
-
- ~ObjectStorage() { destruct_on_exit<T>(); }
-
- template <typename... Args>
- void construct(Args&&... args)
+ namespace Benchmark {
+ namespace Detail {
+ template <typename T, bool Destruct>
+ struct ObjectStorage
{
- new (&data) T(std::forward<Args>(args)...);
- }
-
- template <bool AllowManualDestruction = !Destruct>
- typename std::enable_if<AllowManualDestruction>::type destruct()
- {
- stored_object().~T();
- }
-
- private:
- // If this is a constructor benchmark, destruct the underlying object
- template <typename U>
- void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); }
- // Otherwise, don't
- template <typename U>
- void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { }
-
- T& stored_object()
- {
- return *static_cast<T*>(static_cast<void*>(&data));
- }
-
- TStorage data;
- };
- }
-
- template <typename T>
- using storage_for = Detail::ObjectStorage<T, true>;
-
- template <typename T>
- using destructable_object = Detail::ObjectStorage<T, false>;
-}
+ using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
+
+ ObjectStorage() : data() {}
+
+ ObjectStorage(const ObjectStorage& other)
+ {
+ new(&data) T(other.stored_object());
+ }
+
+ ObjectStorage(ObjectStorage&& other)
+ {
+ new(&data) T(std::move(other.stored_object()));
+ }
+
+ ~ObjectStorage() { destruct_on_exit<T>(); }
+
+ template <typename... Args>
+ void construct(Args&&... args)
+ {
+ new (&data) T(std::forward<Args>(args)...);
+ }
+
+ template <bool AllowManualDestruction = !Destruct>
+ typename std::enable_if<AllowManualDestruction>::type destruct()
+ {
+ stored_object().~T();
+ }
+
+ private:
+ // If this is a constructor benchmark, destruct the underlying object
+ template <typename U>
+ void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); }
+ // Otherwise, don't
+ template <typename U>
+ void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { }
+
+ T& stored_object()
+ {
+ return *static_cast<T*>(static_cast<void*>(&data));
+ }
+
+ TStorage data;
+ };
+ } // namespace Detail
+
+ template <typename T>
+ using storage_for = Detail::ObjectStorage<T, true>;
+
+ template <typename T>
+ using destructable_object = Detail::ObjectStorage<T, false>;
+ } // namespace Benchmark
+} // namespace Catch
#endif // TWOBLUECUBES_CATCH_CONSTRUCTOR_HPP_INCLUDED