19namespace pw::multibuf {
22enum class Property : uint8_t {
45constexpr bool PropertiesAreInOrderWithoutDuplicates() {
48template <Property kLhs, Property kRhs, Property... kOthers>
49constexpr bool PropertiesAreInOrderWithoutDuplicates() {
50 return (kLhs < kRhs) &&
51 PropertiesAreInOrderWithoutDuplicates<kRhs, kOthers...>();
56template <Property... kProperties>
57constexpr bool PropertiesAreValid() {
58 if constexpr (
sizeof...(kProperties) != 0) {
59 static_assert(PropertiesAreInOrderWithoutDuplicates<kProperties...>(),
60 "Properties must be specified in the following order, "
61 "without duplicates: kConst, kLayerable, kObservable");
80template <Property... kProperties>
86template <
typename From,
typename To>
87using EnableIfConvertible =
88 std::enable_if_t<std::is_same_v<To, internal::GenericMultiBuf> ||
92 (!From::is_const() || To::is_const()) &&
94 (From::is_layerable() || !To::is_layerable()) &&
97 (From::is_observable() || !To::is_observable()))>;
101template <
typename From,
typename To>
102static constexpr void AssertIsConvertible() {
103 if constexpr (!std::is_same_v<To, internal::GenericMultiBuf>) {
105 "Only conversion to other MultiBuf types are supported.");
106 static_assert(!From::is_const() || To::is_const(),
107 "Read-only data cannot be converted to mutable data.");
108 static_assert(From::is_layerable() || !To::is_layerable(),
109 "Flat MultiBufs do not have layer-related methods.");
110 static_assert(From::is_observable() || !To::is_observable(),
111 "Untracked MultiBufs do not have observer-related methods.");
Definition: multibuf_v2.h:217
Type trait to identify MultiBuf types.
Definition: properties.h:78