Path: blob/main/contrib/llvm-project/libcxx/include/__functional/bind_front.h
35260 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_BIND_FRONT_H10#define _LIBCPP___FUNCTIONAL_BIND_FRONT_H1112#include <__config>13#include <__functional/invoke.h>14#include <__functional/perfect_forward.h>15#include <__type_traits/conjunction.h>16#include <__type_traits/decay.h>17#include <__type_traits/enable_if.h>18#include <__type_traits/is_constructible.h>19#include <__utility/forward.h>2021#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22# pragma GCC system_header23#endif2425_LIBCPP_BEGIN_NAMESPACE_STD2627#if _LIBCPP_STD_VER >= 202829struct __bind_front_op {30template <class... _Args>31_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const noexcept(32noexcept(std::invoke(std::forward<_Args>(__args)...))) -> decltype(std::invoke(std::forward<_Args>(__args)...)) {33return std::invoke(std::forward<_Args>(__args)...);34}35};3637template <class _Fn, class... _BoundArgs>38struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> {39using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward;40};4142template <class _Fn, class... _Args>43requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&44(is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)45_LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) {46return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);47}4849#endif // _LIBCPP_STD_VER >= 205051_LIBCPP_END_NAMESPACE_STD5253#endif // _LIBCPP___FUNCTIONAL_BIND_FRONT_H545556