brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 427accf Raw
55 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_BIND_FRONT_H11#define _LIBCPP___FUNCTIONAL_BIND_FRONT_H12 13#include <__config>14#include <__functional/invoke.h>15#include <__functional/perfect_forward.h>16#include <__type_traits/conjunction.h>17#include <__type_traits/decay.h>18#include <__type_traits/enable_if.h>19#include <__type_traits/is_constructible.h>20#include <__utility/forward.h>21 22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#  pragma GCC system_header24#endif25 26_LIBCPP_BEGIN_NAMESPACE_STD27 28#if _LIBCPP_STD_VER >= 2029 30struct __bind_front_op {31  template <class... _Args>32  _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const noexcept(33      noexcept(std::invoke(std::forward<_Args>(__args)...))) -> decltype(std::invoke(std::forward<_Args>(__args)...)) {34    return std::invoke(std::forward<_Args>(__args)...);35  }36};37 38template <class _Fn, class... _BoundArgs>39struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> {40  using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward;41};42 43template <class _Fn, class... _Args>44  requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&45           (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)46[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) {47  return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);48}49 50#endif // _LIBCPP_STD_VER >= 2051 52_LIBCPP_END_NAMESPACE_STD53 54#endif // _LIBCPP___FUNCTIONAL_BIND_FRONT_H55