Back to home page

EIC code displayed by LXR

 
 

    


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

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___CXX03___FUNCTIONAL_BIND_FRONT_H
0011 #define _LIBCPP___CXX03___FUNCTIONAL_BIND_FRONT_H
0012 
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__functional/invoke.h>
0015 #include <__cxx03/__functional/perfect_forward.h>
0016 #include <__cxx03/__type_traits/conjunction.h>
0017 #include <__cxx03/__type_traits/decay.h>
0018 #include <__cxx03/__type_traits/enable_if.h>
0019 #include <__cxx03/__type_traits/is_constructible.h>
0020 #include <__cxx03/__utility/forward.h>
0021 
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 #  pragma GCC system_header
0024 #endif
0025 
0026 _LIBCPP_BEGIN_NAMESPACE_STD
0027 
0028 #if _LIBCPP_STD_VER >= 20
0029 
0030 struct __bind_front_op {
0031   template <class... _Args>
0032   _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const noexcept(
0033       noexcept(std::invoke(std::forward<_Args>(__args)...))) -> decltype(std::invoke(std::forward<_Args>(__args)...)) {
0034     return std::invoke(std::forward<_Args>(__args)...);
0035   }
0036 };
0037 
0038 template <class _Fn, class... _BoundArgs>
0039 struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> {
0040   using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward;
0041 };
0042 
0043 template <class _Fn, class... _Args>
0044   requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&
0045            (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)
0046 _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) {
0047   return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);
0048 }
0049 
0050 #endif // _LIBCPP_STD_VER >= 20
0051 
0052 _LIBCPP_END_NAMESPACE_STD
0053 
0054 #endif // _LIBCPP___CXX03___FUNCTIONAL_BIND_FRONT_H