Path: blob/main/contrib/llvm-project/libcxx/include/__utility/forward.h
35236 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___UTILITY_FORWARD_H10#define _LIBCPP___UTILITY_FORWARD_H1112#include <__config>13#include <__type_traits/is_reference.h>14#include <__type_traits/remove_reference.h>1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17# pragma GCC system_header18#endif1920_LIBCPP_BEGIN_NAMESPACE_STD2122template <class _Tp>23_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&24forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT {25return static_cast<_Tp&&>(__t);26}2728template <class _Tp>29_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&30forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT {31static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");32return static_cast<_Tp&&>(__t);33}3435_LIBCPP_END_NAMESPACE_STD3637#endif // _LIBCPP___UTILITY_FORWARD_H383940