Path: blob/main/contrib/llvm-project/libcxx/include/__functional/compose.h
35259 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___FUNCTIONAL_COMPOSE_H10#define _LIBCPP___FUNCTIONAL_COMPOSE_H1112#include <__config>13#include <__functional/invoke.h>14#include <__functional/perfect_forward.h>15#include <__type_traits/decay.h>16#include <__utility/forward.h>1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19# pragma GCC system_header20#endif2122_LIBCPP_BEGIN_NAMESPACE_STD2324#if _LIBCPP_STD_VER >= 202526struct __compose_op {27template <class _Fn1, class _Fn2, class... _Args>28_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const noexcept(noexcept(29std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))))30-> decltype(std::invoke(std::forward<_Fn1>(__f1),31std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))) {32return std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...));33}34};3536template <class _Fn1, class _Fn2>37struct __compose_t : __perfect_forward<__compose_op, _Fn1, _Fn2> {38using __perfect_forward<__compose_op, _Fn1, _Fn2>::__perfect_forward;39};4041template <class _Fn1, class _Fn2>42_LIBCPP_HIDE_FROM_ABI constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2) noexcept(43noexcept(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))))44-> decltype(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))) {45return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2));46}4748#endif // _LIBCPP_STD_VER >= 204950_LIBCPP_END_NAMESPACE_STD5152#endif // _LIBCPP___FUNCTIONAL_COMPOSE_H535455