File tree Expand file tree Collapse file tree 5 files changed +15
-10
lines changed
Expand file tree Collapse file tree 5 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 1212
1313namespace simply {
1414
15+ // TODO reconsider template parameters to avoid requiring user to explicitly
16+ // categorize affordances, or provide a type alias template to categorize them
17+ // and inject defaults. Rename to `basic_dyn`?
1518template <simply::affordance Affordance,
1619 simply::storage_affordance Storage = simply::allocator_storage<>,
1720 simply::dispatch_affordance Dispatch = simply::indirect_dispatch>
Original file line number Diff line number Diff line change 77
88namespace simply {
99
10- template <typename Affordance, typename T,
11- typename Fn = affordance_traits<Affordance, T>::function_type>
10+ template <typename Affordance, typename T, typename Fn>
1211struct impl {
1312 static constexpr auto fn = Affordance::template fn<T>;
1413};
1514
1615template <typename Affordance, typename T>
1716inline constexpr const auto &fn = simply::impl<Affordance, T>::fn;
1817
18+ // TODO consider `bind<Affordance>(self)(rest...)` as an alternative to
19+ // `fn<Affordance, remove_cvref_t<decltype(self)>>(self, rest...)` that exposes
20+ // operator() as an overload set with non-deduced parameter types
21+
1922template <simply::member_affordance Affordance, typename T>
2023struct affordance_traits <Affordance, T> {
2124 using function_type = decltype (Affordance::template fn<T>);
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ struct iface<Storage, Self> {
7373 using void_pointer = traits::void_pointer;
7474 using const_void_pointer = traits::const_void_pointer;
7575
76- // TODO use this->alloc instead of other.alloc to copy other->object_ptr
76+ // BUG use this->alloc instead of other.alloc to copy other->object_ptr
7777 constexpr iface (const iface &other)
7878 : alloc(traits::select_on_container_copy_construction(other.alloc)),
7979 object_ptr(
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ struct dispatch_affordance_base : simply::affordance_base {};
2727template <typename Affordance, typename T>
2828struct affordance_traits ;
2929
30+ template <typename Affordance, typename T,
31+ typename Fn = affordance_traits<Affordance, T>::function_type>
32+ struct impl ;
33+
3034template <typename Affordance, typename Tag>
3135struct fundamental_affordance_type {};
3236
@@ -76,10 +80,9 @@ template <typename T>
7680inline constexpr bool enable_affordance =
7781 std::derived_from<T, simply::affordance_base>;
7882
79- // TODO integrate this customization point with impl and/or affordance_traits
8083template <typename Affordance, typename T>
8184inline constexpr bool enable_affordance_for =
82- requires { &Affordance:: template fn<T> ; };
85+ requires { simply::impl<Affordance, T>::fn ; };
8386
8487template <typename T, typename Tag>
8588inline constexpr bool enable_affordance_tag = std::derived_from<T, Tag>;
Original file line number Diff line number Diff line change @@ -63,12 +63,8 @@ static_assert([] {
6363 : simply::composes<copy_countable<int >, labeled<char >,
6464 simply::copy_constructible, simply::destructible> {};
6565
66- using dyn = simply::dyn<countable>;
67- static_assert (requires {
68- typename simply::affordance_traits<copy_countable<int >, dyn>::function_type;
69- });
7066 // initialize a vector of dyn<countable> with three different counter types
71- std::vector<dyn> v;
67+ std::vector<simply:: dyn<countable> > v;
7268 v.emplace_back (std::in_place_type<counter<' A' >>);
7369 v.emplace_back (std::in_place_type<counter<' B' >>);
7470 v.emplace_back (std::in_place_type<counter<' C' >>);
You can’t perform that action at this time.
0 commit comments