computation_store.cpp serif/utils/dependencies/computation_store.hpp concepts memory type_traits utility #include"serif/utils/dependencies/computation_store.hpp" #include<concepts> #include<memory> #include<type_traits> #include<utility> namespace{ namespacedependencies=serif::utils::dependencies; structFirst{}; structSecond{}; structMissing{}; usingFirstEntry=decltype(dependencies::own_computation<First>(1)); usingSecondEntry=decltype(dependencies::own_computation<Second>(2)); usingStore=dependencies::ComputationStore<FirstEntry,SecondEntry>; template<typenameValueT> conceptCanOwn=requires(ValueT&&value){ dependencies::own_computation<First>(std::forward<ValueT>(value)); }; template<typename...EntryTs> conceptCanMakeStore=requires(EntryTs&&...entries){ dependencies::make_computation_store(std::forward<EntryTs>(entries)...); }; template<typenameStoreT,typenameKeyT> conceptCanRead=requires(StoreT&&store){ std::forward<StoreT>(store).templateget<KeyT>(); }; template<typenameEntryT> conceptCanReadEntry=requires(EntryT&&entry){ std::forward<EntryT>(entry).get(); }; static_assert(dependencies::IsOwnedComputation<FirstEntry>); static_assert(dependencies::IsOwnedComputation<constFirstEntry&>); static_assert(!dependencies::IsOwnedComputation<int>); static_assert(CanOwn<int>&&CanOwn<int&>&&CanOwn<const int&>); static_assert(CanOwn<std::unique_ptr<int>>); static_assert(!CanOwn<std::unique_ptr<int>&>); static_assert(!CanOwn<const std::unique_ptr<int>&>); static_assert(CanMakeStore<>); static_assert(CanMakeStore<FirstEntry, SecondEntry>); static_assert(!CanMakeStore<FirstEntry, FirstEntry>); static_assert(!CanMakeStore<FirstEntry&>); static_assert(!CanMakeStore<const FirstEntry&>); static_assert(!CanMakeStore<int>); static_assert(CanRead<Store&, First>&&CanRead<const Store&, Second>); static_assert(!CanRead<Store&, Missing>); static_assert(!CanRead<Store, First>&&!CanRead<const Store, First>); static_assert(CanReadEntry<FirstEntry&>&&CanReadEntry<const FirstEntry&>); static_assert(!CanReadEntry<FirstEntry>&&!CanReadEntry<const FirstEntry>); static_assert(std::same_as<decltype(std::declval<Store&>().get<First>()),int&>); static_assert(std::same_as<decltype(std::declval<constStore&>().get<First>()),constint&>); static_assert(std::same_as<dependencies::bound_type_t<Store::Bindings,First>,int>); static_assert(std::is_nothrow_move_constructible_v<Store>); static_assert(!std::is_copy_constructible_v<Store>); static_assert(!std::is_move_assignable_v<Store>&&!std::is_copy_assignable_v<Store>); }