45namespace multibuf_impl {
51template <MultiBufProperty>
52constexpr bool PropertiesAreInOrderWithoutDuplicates() {
58constexpr bool PropertiesAreInOrderWithoutDuplicates() {
59 return (kLhs < kRhs) &&
60 PropertiesAreInOrderWithoutDuplicates<kRhs, kOthers...>();
66constexpr bool PropertiesAreValid() {
67 if constexpr (
sizeof...(kProperties) != 0) {
68 static_assert(PropertiesAreInOrderWithoutDuplicates<kProperties...>(),
69 "Properties must be specified in the following order, "
70 "without duplicates: kConst, kLayerable, kObservable");
85template <
typename From,
typename To>
86using EnableIfConvertible =
87 std::enable_if_t<std::is_same_v<To, GenericMultiBuf> ||
91 (!From::is_const() || To::is_const()) &&
93 (From::is_layerable() || !To::is_layerable()) &&
96 (From::is_observable() || !To::is_observable()))>;
100template <
typename From,
typename To>
101static constexpr void AssertIsConvertible() {
102 if constexpr (!std::is_same_v<To, GenericMultiBuf>) {
104 "Only conversion to other MultiBuf types are supported.");
105 static_assert(!From::is_const() || To::is_const(),
106 "Read-only data cannot be converted to mutable data.");
107 static_assert(From::is_layerable() || !To::is_layerable(),
108 "Flat MultiBufs do not have layer-related methods.");
109 static_assert(From::is_observable() || !To::is_observable(),
110 "Untracked MultiBufs do not have observer-related methods.");
Definition: multibuf_v2.h:192
MultiBufProperty
Basic properties of a MultiBuf.
Definition: properties.h:24
The Pigweed namespace.
Definition: alignment.h:27
Type trait to identify MultiBuf types.
Definition: properties.h:77