@@ -715,26 +715,65 @@ class method<Name, Return(Parameters...), Options...>
715
715
detail::types<OverriderParameters...>>>;
716
716
};
717
717
718
- template <class Container , bool has_next>
719
- struct override_ ;
718
+ template <auto Function>
719
+ struct override_fn_impl {
720
+ explicit override_fn_impl (Next* next = nullptr ) {
721
+ static detail::definition_info info;
720
722
721
- friend class generator ;
723
+ if (info.method ) {
724
+ BOOST_ASSERT (info.method == &fn);
725
+ return ;
726
+ }
722
727
723
- public:
724
- template <auto Function>
725
- struct override_fn ;
728
+ info.method = &fn;
729
+ info.type = Policy::template static_type<decltype (Function)>();
730
+ info.next = reinterpret_cast <void **>(next);
731
+ using Thunk = thunk<Function, decltype (Function)>;
732
+ info.pf = (void *)Thunk::fn;
733
+ info.vp_begin = Thunk::OverriderParameterTypeIds::begin;
734
+ info.vp_end = Thunk::OverriderParameterTypeIds::end;
735
+ fn.specs .push_back (info);
736
+ }
737
+ };
738
+
739
+ template <auto Function, typename FunctionType>
740
+ struct override_fn_aux ;
741
+
742
+ template <auto Function, typename FnReturnType, typename ... FnParameters>
743
+ struct override_fn_aux <Function, FnReturnType (*)(FnParameters...)>
744
+ : override_fn_impl<Function> {
745
+ using override_fn_impl<Function>::override_fn_impl;
746
+ };
747
+
748
+ template <
749
+ auto Function, class FnClass , typename FnReturnType,
750
+ typename ... FnParameters>
751
+ struct override_fn_aux <
752
+ Function, FnReturnType (FnClass::*)(FnParameters...)> {
753
+ static auto fn (FnClass* this_, FnParameters&&... args) -> FnReturnType {
754
+ return (this_->*Function)(std::forward<FnParameters>(args)...);
755
+ }
756
+
757
+ override_fn_impl<fn> impl;
758
+ };
759
+
760
+ template <class Container , bool HasNext>
761
+ struct override_aux ;
726
762
727
- private:
728
763
template <class Container >
729
- struct override_ <Container, false > {
730
- override_fn<Container::fn> override_{nullptr };
764
+ struct override_aux <Container, false > : override_fn<Container::fn> {
765
+ override_aux () : override_fn<Container::fn>(nullptr ) {
766
+ }
731
767
};
732
768
733
769
template <class Container >
734
- struct override_ <Container, true > {
735
- override_fn<Container::fn> add{&Container::next};
770
+ struct override_aux <Container, true > : override_fn<Container::fn> {
771
+ override_aux () : override_fn<Container::fn>(&Container::next) {
772
+ }
736
773
};
737
774
775
+ friend class generator ;
776
+
738
777
public:
739
778
// Public aliases.
740
779
using return_type = Return;
@@ -754,38 +793,20 @@ class method<Name, Return(Parameters...), Options...>
754
793
using next = detail::next_aux<method, Container>;
755
794
756
795
template <auto Function>
757
- struct override_fn {
758
- explicit override_fn (Next* next = nullptr ) {
759
- static detail::definition_info info;
760
-
761
- if (info.method ) {
762
- BOOST_ASSERT (info.method == &fn);
763
- return ;
764
- }
796
+ struct override_fn : override_fn_aux<Function, decltype (Function)> {
797
+ using override_fn_aux<Function, decltype (Function)>::override_fn_aux;
798
+ };
765
799
766
- info.method = &fn;
767
- info.type = Policy::template static_type<decltype (Function)>();
768
- info.next = reinterpret_cast <void **>(next);
769
- using Thunk = thunk<Function, decltype (Function)>;
770
- info.pf = (void *)Thunk::fn;
771
- info.vp_begin = Thunk::OverriderParameterTypeIds::begin;
772
- info.vp_end = Thunk::OverriderParameterTypeIds::end;
773
- fn.specs .push_back (info);
774
- }
800
+ template <auto ... F>
801
+ struct override_fns {
802
+ std::tuple<override_fn<F>...> fns;
775
803
};
776
804
777
805
template <class Container >
778
806
struct override
779
- : override_ <Container, detail::has_next<Container>::value> {
807
+ : override_aux <Container, detail::has_next<Container>::value> {
780
808
using type = override ; // make it a meta-function
781
809
};
782
-
783
- template <auto F>
784
- struct add_member_function
785
- : override_fn<detail::member_function_thunk<F, decltype (F)>::fn> {};
786
-
787
- template <auto ... F>
788
- struct add_member_functions : std::tuple<add_member_function<F>...> {};
789
810
};
790
811
791
812
template <
0 commit comments