File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed
source/code/core/collections/public/ice Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ #pragma once
2+ #include < ice/types/ncount.hxx>
3+ #include < ice/types/nindex.hxx>
4+
5+ namespace ice ::concepts
6+ {
7+
8+ template <typename T>
9+ concept ContiguousContainer = requires (T t) {
10+ { t.size () } -> std::convertible_to<ice::ncount>;
11+ { t.data () } -> std::convertible_to<typename T::ValueType const *>;
12+ };
13+
14+ } // namespace ice::concepts
15+
16+ namespace ice ::container
17+ {
18+
19+ template <typename ContainerT>
20+ using ValueRef = ice::const_correct_t <std::remove_reference_t <ContainerT>, typename ContainerT::ValueType>&;
21+
22+ template <typename ContainerT>
23+ using ValuePtr = ice::const_correct_t <std::remove_reference_t <ContainerT>, typename ContainerT::ValueType>*;
24+
25+ } // namespace ice::container
Original file line number Diff line number Diff line change 1+ #pragma once
2+ #include < ice/container/container_concepts.hxx>
3+
4+ namespace ice ::container
5+ {
6+
7+ struct ContiguousContainer
8+ {
9+ template <ice::concepts::ContiguousContainer Self>
10+ constexpr auto front (this Self& self) noexcept -> ice::container::ValueRef<Self>
11+ {
12+ return self.data ()[0 ];
13+ }
14+ };
15+
16+ } // namespace ice::container
Original file line number Diff line number Diff line change 33
44#pragma once
55#include < ice/mem_allocator.hxx>
6+ #include < ice/container/contiguous_container.hxx>
7+
68#include < ice/container_logic.hxx>
79#include < ice/string_types.hxx>
810#include < ice/span.hxx>
911#include < array>
1012
1113namespace ice
1214{
15+ struct Test : ice::container::ContiguousContainer
16+ {
17+ using ValueType = int ;
18+
19+ int foo[4 ];
20+
21+ template <typename Self>
22+ constexpr auto data (this Self& self) noexcept -> ice::const_correct_t<Self, ValueType>* { return self.foo ; }
23+ constexpr ncount size () const noexcept { return 4 ; }
24+ };
1325
1426 // ! \brief A simple contaier storing items in contignous memory.
1527 // !
You can’t perform that action at this time.
0 commit comments