brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 4b86dd3 Raw
54 lines · c
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___FUNCTIONAL_COMPOSE_H11#define _LIBCPP___FUNCTIONAL_COMPOSE_H12 13#include <__config>14#include <__functional/invoke.h>15#include <__functional/perfect_forward.h>16#include <__type_traits/decay.h>17#include <__utility/forward.h>18 19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#  pragma GCC system_header21#endif22 23_LIBCPP_BEGIN_NAMESPACE_STD24 25#if _LIBCPP_STD_VER >= 2026 27struct __compose_op {28  template <class _Fn1, class _Fn2, class... _Args>29  _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const noexcept(noexcept(30      std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))))31      -> decltype(std::invoke(std::forward<_Fn1>(__f1),32                              std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))) {33    return std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...));34  }35};36 37template <class _Fn1, class _Fn2>38struct __compose_t : __perfect_forward<__compose_op, _Fn1, _Fn2> {39  using __perfect_forward<__compose_op, _Fn1, _Fn2>::__perfect_forward;40};41 42template <class _Fn1, class _Fn2>43_LIBCPP_HIDE_FROM_ABI constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2) noexcept(44    noexcept(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))))45    -> decltype(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))) {46  return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2));47}48 49#endif // _LIBCPP_STD_VER >= 2050 51_LIBCPP_END_NAMESPACE_STD52 53#endif // _LIBCPP___FUNCTIONAL_COMPOSE_H54