Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 08:48:10

0001 //           Copyright Maksym Zhelyenzyakov 2025-2026.
0002 // Distributed under the Boost Software License, Version 1.0.
0003 //      (See accompanying file LICENSE_1_0.txt or copy at
0004 //           https://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef REVERSE_MODE_AUTODIFF_UTILITIES_HPP
0006 #define REVERSE_MODE_AUTODIFF_UTILITIES_HPP
0007 
0008 #include <utility>
0009 
0010 namespace boost {
0011 namespace math {
0012 namespace differentiation {
0013 namespace reverse_mode {
0014 namespace detail {
0015 
0016 template<bool Condition>
0017 struct if_functional_dispatch_impl;
0018 
0019 template<>
0020 struct if_functional_dispatch_impl<true>
0021 {
0022     template<typename F1, typename F2, typename... Args>
0023     static decltype(auto) call(F1&& f1, F2&&, Args&&... args)
0024     {
0025         return std::forward<F1>(f1)(std::forward<Args>(args)...);
0026     }
0027 };
0028 
0029 template<>
0030 struct if_functional_dispatch_impl<false>
0031 {
0032     template<typename F1, typename F2, typename... Args>
0033     static decltype(auto) call(F1&&, F2&& f2, Args&&... args)
0034     {
0035         return std::forward<F2>(f2)(std::forward<Args>(args)...);
0036     }
0037 };
0038 
0039 template<bool Condition, typename F1, typename F2, typename... Args>
0040 decltype(auto) if_functional_dispatch(F1&& f1, F2&& f2, Args&&... args)
0041 {
0042     return if_functional_dispatch_impl<Condition>::call(std::forward<F1>(f1),
0043                                                         std::forward<F2>(f2),
0044                                                         std::forward<Args>(args)...);
0045 }
0046 } // namespace detail
0047 } // namespace reverse_mode
0048 } // namespace differentiation
0049 } // namespace math
0050 } // namespace boost
0051 #endif // REVERSE_MODE_AUTODIFF_UTILITIES_HPP