Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,27 @@ cc_library(
copts = ["-std=c++20"],
)

cc_library(
name = "sub_struct_view",
hdrs = ["include/fixed_containers/sub_struct_view.hpp"],
includes = includes_config(),
strip_include_prefix = strip_include_prefix_config(),
deps = [
":assert_or_abort",
":fixed_vector",
":fixed_map",
":fixed_set",
":iterator_utils",
":memory",
":in_out",
":out",
":random_access_iterator",
":reflection",
":type_name"
],
copts = ["-std=c++20"],
)

cc_library(
name = "tuples",
hdrs = [
Expand Down Expand Up @@ -1588,6 +1609,20 @@ cc_test(
copts = ["-std=c++20"],
)

cc_test(
name = "sub_struct_view_test",
srcs = ["test/sub_struct_view_test.cpp"],
deps = [
":fixed_vector",
":out",
":sub_struct_view",
":source_location",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
copts = ["-std=c++20"],
)

cc_test(
name = "tuples_test",
srcs = ["test/tuples_test.cpp"],
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ if(BUILD_TESTS)
add_test_dependencies(stack_adapter_test)
add_executable(string_literal_test test/string_literal_test.cpp)
add_test_dependencies(string_literal_test)
add_executable(sub_struct_view_test test/sub_struct_view_test.cpp)
add_test_dependencies(sub_struct_view_test)
add_executable(tuples_test test/tuples_test.cpp)
add_test_dependencies(tuples_test)
add_executable(type_name_test test/type_name_test.cpp)
Expand Down
4 changes: 2 additions & 2 deletions include/fixed_containers/index_or_value_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ union IndexOrValueStorage
explicit constexpr IndexOrValueStorage(const T& var) : value{var} { }
explicit constexpr IndexOrValueStorage(T&& var) : value{std::move(var)} { }
template <class... Args>
explicit constexpr IndexOrValueStorage(std::in_place_t /*unused*/, Args&&... args) : value(std::forward<Args>(args)...) { }
explicit constexpr IndexOrValueStorage(std::in_place_t /*unused*/, Args&&... args) : value{std::forward<Args>(args)...} { }

constexpr IndexOrValueStorage(const IndexOrValueStorage&) requires TriviallyCopyConstructible<T> = default;
constexpr IndexOrValueStorage(IndexOrValueStorage&&) noexcept requires TriviallyMoveConstructible<T> = default;
Expand Down Expand Up @@ -61,7 +61,7 @@ union IndexOrValueStorage<T>
explicit constexpr IndexOrValueStorage(const T& var) : value{var} { }
explicit constexpr IndexOrValueStorage(T&& var) : value{std::move(var)} { }
template <class... Args>
explicit constexpr IndexOrValueStorage(std::in_place_t /*unused*/, Args&&... args) : value(std::forward<Args>(args)...) { }
explicit constexpr IndexOrValueStorage(std::in_place_t /*unused*/, Args&&... args) : value{std::forward<Args>(args)...} { }
// clang-format on
constexpr IndexOrValueStorage(const IndexOrValueStorage&) = default;
constexpr IndexOrValueStorage(IndexOrValueStorage&&) noexcept = default;
Expand Down
11 changes: 11 additions & 0 deletions include/fixed_containers/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ constexpr void destroy_and_construct_at_address_of(T& ref, Args&&... args)
construct_at_address_of(ref, std::forward<Args>(args)...);
}

template <typename T>
const std::byte* addressof_as_const_byte_ptr(T& ref)
{
return reinterpret_cast<const std::byte*>(std::addressof(ref));
}
template <typename T>
std::byte* addressof_as_mutable_byte_ptr(T& ref)
{
return reinterpret_cast<std::byte*>(std::addressof(ref));
}

} // namespace fixed_containers::memory
4 changes: 2 additions & 2 deletions include/fixed_containers/optional_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ union OptionalStorage
explicit constexpr OptionalStorage(const T& var) : value{var} { }
explicit constexpr OptionalStorage(T&& var) : value{std::move(var)} { }
template <class... Args>
explicit constexpr OptionalStorage(std::in_place_t /*unused*/, Args&&... args) : value(std::forward<Args>(args)...) { }
explicit constexpr OptionalStorage(std::in_place_t /*unused*/, Args&&... args) : value{std::forward<Args>(args)...} { }

constexpr OptionalStorage(const OptionalStorage&) requires TriviallyCopyConstructible<T> = default;
constexpr OptionalStorage(OptionalStorage&&) noexcept requires TriviallyMoveConstructible<T> = default;
Expand Down Expand Up @@ -70,7 +70,7 @@ union OptionalStorage<T>
explicit constexpr OptionalStorage(const T& var) : value{var} { }
explicit constexpr OptionalStorage(T&& var) : value{std::move(var)} { }
template <class... Args>
explicit constexpr OptionalStorage(std::in_place_t /*unused*/, Args&&... args) : value(std::forward<Args>(args)...) { }
explicit constexpr OptionalStorage(std::in_place_t /*unused*/, Args&&... args) : value{std::forward<Args>(args)...} { }

// clang-format on
constexpr OptionalStorage(const OptionalStorage&) = default;
Expand Down
Loading