From 4279d7aa574cfec85d4ff9d8f1535403cb40e17c Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Tue, 3 Jan 2023 09:26:30 +0700 Subject: [PATCH] add a little clarification in the examples --- manuals/meta_examples/inplace_example.cpp | 5 ++++- untests/meta_states/ctor_tests.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/manuals/meta_examples/inplace_example.cpp b/manuals/meta_examples/inplace_example.cpp index 01400cd..e21cbb9 100644 --- a/manuals/meta_examples/inplace_example.cpp +++ b/manuals/meta_examples/inplace_example.cpp @@ -12,7 +12,7 @@ namespace int x; int y; - ivec2(int xy) : x{xy}, y{xy} {} + explicit ivec2(int nv) : x{nv}, y{nv} {} ivec2(int nx, int ny) : x{nx}, y{ny} {} int length2() const noexcept { @@ -47,6 +47,9 @@ TEST_CASE("meta/meta_examples/inplace") { ivec2_type.get_size(), std::align_val_t{ivec2_type.get_align()}}; + // or you can use static buffer instead (if the required type is available at compile-time) + // alignas(ivec2) std::byte ivec2_buffer[sizeof(ivec2)]; + // creates 'ivec2' on the memory buffer ('placement new' under the hood) const meta::uvalue ivec2_ptr = ivec2_type.create_at(ivec2_buffer.get_memory(), 2, 3); diff --git a/untests/meta_states/ctor_tests.cpp b/untests/meta_states/ctor_tests.cpp index c1484a8..201c6a2 100644 --- a/untests/meta_states/ctor_tests.cpp +++ b/untests/meta_states/ctor_tests.cpp @@ -139,7 +139,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { const meta::class_type clazz_type = meta::resolve_type(); REQUIRE(clazz_type); - alignas(alignof(clazz_t)) std::byte clazz_mem[sizeof(clazz_t)]; + alignas(clazz_t) std::byte clazz_mem[sizeof(clazz_t)]; SUBCASE("int") { {