MCPcopy Create free account
hub / github.com/Naios/function2 / erasure

Class erasure

include/function2/function2.hpp:1130–1245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1128/// An owning erasure
1129template <bool IsOwning /* = true*/, typename Config, typename Property>
1130class erasure : internal_capacity_holder<typename Config::capacity> {
1131 template <bool, typename, typename>
1132 friend class erasure;
1133 template <std::size_t, typename, typename...>
1134 friend class operator_impl;
1135
1136 using vtable_t = tables::vtable<Property>;
1137
1138 vtable_t vtable_;
1139
1140public:
1141 /// Returns the capacity of this erasure
1142 static constexpr std::size_t capacity() noexcept {
1143 return internal_capacity_holder<typename Config::capacity>::capacity();
1144 }
1145
1146 FU2_DETAIL_CXX14_CONSTEXPR erasure() noexcept {
1147 vtable_.set_empty();
1148 }
1149
1150 FU2_DETAIL_CXX14_CONSTEXPR erasure(std::nullptr_t) noexcept {
1151 vtable_.set_empty();
1152 }
1153
1154 FU2_DETAIL_CXX14_CONSTEXPR
1155 erasure(erasure&& right) noexcept(Property::is_strong_exception_guaranteed) {
1156 right.vtable_.move(vtable_, right.opaque_ptr(), right.capacity(),
1157 this->opaque_ptr(), capacity());
1158 }
1159
1160 FU2_DETAIL_CXX14_CONSTEXPR erasure(erasure const& right) {
1161 right.vtable_.copy(vtable_, right.opaque_ptr(), right.capacity(),
1162 this->opaque_ptr(), capacity());
1163 }
1164
1165 template <typename OtherConfig>
1166 FU2_DETAIL_CXX14_CONSTEXPR
1167 erasure(erasure<true, OtherConfig, Property> right) noexcept(
1168 Property::is_strong_exception_guaranteed) {
1169 right.vtable_.move(vtable_, right.opaque_ptr(), right.capacity(),
1170 this->opaque_ptr(), capacity());
1171 }
1172
1173 template <typename T, typename Allocator = std::allocator<std::decay_t<T>>>
1174 FU2_DETAIL_CXX14_CONSTEXPR erasure(std::false_type /*use_bool_op*/,
1175 T&& callable,
1176 Allocator&& allocator_ = Allocator{}) {
1177 vtable_t::init(vtable_,
1178 type_erasure::make_box(
1179 std::integral_constant<bool, Config::is_copyable>{},
1180 std::forward<T>(callable),
1181 std::forward<Allocator>(allocator_)),
1182 this->opaque_ptr(), capacity());
1183 }
1184 template <typename T, typename Allocator = std::allocator<std::decay_t<T>>>
1185 FU2_DETAIL_CXX14_CONSTEXPR erasure(std::true_type /*use_bool_op*/,
1186 T&& callable,
1187 Allocator&& allocator_ = Allocator{}) {

Callers

nothing calls this directly

Calls 6

destroyMethod · 0.80
opaque_ptrMethod · 0.80
weak_destroyMethod · 0.80
moveMethod · 0.80
copyMethod · 0.80
capacityMethod · 0.45

Tested by

no test coverage detected