// Copyright Maksym Zhelyeznyakov 2025-2026. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) #ifndef REVERSE_MODE_AUTODIFF_UTILITIES_HPP #define REVERSE_MODE_AUTODIFF_UTILITIES_HPP #include namespace boost { namespace math { namespace differentiation { namespace reverse_mode { namespace detail { template struct if_functional_dispatch_impl; template<> struct if_functional_dispatch_impl { template static decltype(auto) call(F1&& f1, F2&&, Args&&... args) { return std::forward(f1)(std::forward(args)...); } }; template<> struct if_functional_dispatch_impl { template static decltype(auto) call(F1&&, F2&& f2, Args&&... args) { return std::forward(f2)(std::forward(args)...); } }; template decltype(auto) if_functional_dispatch(F1&& f1, F2&& f2, Args&&... args) { return if_functional_dispatch_impl::call(std::forward(f1), std::forward(f2), std::forward(args)...); } } // namespace detail } // namespace reverse_mode } // namespace differentiation } // namespace math } // namespace boost #endif // REVERSE_MODE_AUTODIFF_UTILITIES_HPP