Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:51

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___FUNCTIONAL_COMPOSE_H
0011 #define _LIBCPP___FUNCTIONAL_COMPOSE_H
0012 
0013 #include <__config>
0014 #include <__functional/invoke.h>
0015 #include <__functional/perfect_forward.h>
0016 #include <__type_traits/decay.h>
0017 #include <__utility/forward.h>
0018 
0019 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0020 #  pragma GCC system_header
0021 #endif
0022 
0023 _LIBCPP_BEGIN_NAMESPACE_STD
0024 
0025 #if _LIBCPP_STD_VER >= 20
0026 
0027 struct __compose_op {
0028   template <class _Fn1, class _Fn2, class... _Args>
0029   _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const noexcept(noexcept(
0030       std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))))
0031       -> decltype(std::invoke(std::forward<_Fn1>(__f1),
0032                               std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))) {
0033     return std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...));
0034   }
0035 };
0036 
0037 template <class _Fn1, class _Fn2>
0038 struct __compose_t : __perfect_forward<__compose_op, _Fn1, _Fn2> {
0039   using __perfect_forward<__compose_op, _Fn1, _Fn2>::__perfect_forward;
0040 };
0041 
0042 template <class _Fn1, class _Fn2>
0043 _LIBCPP_HIDE_FROM_ABI constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2) noexcept(
0044     noexcept(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))))
0045     -> decltype(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))) {
0046   return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2));
0047 }
0048 
0049 #endif // _LIBCPP_STD_VER >= 20
0050 
0051 _LIBCPP_END_NAMESPACE_STD
0052 
0053 #endif // _LIBCPP___FUNCTIONAL_COMPOSE_H