1/*=============================================================================
2 Copyright (c) 2014 Paul Fultz II
3 forward.h
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7
8#ifndef BOOST_HOF_GUARD_FORWARD_H
9#define BOOST_HOF_GUARD_FORWARD_H
10
11#include <utility>
12
13namespace boost { namespace hof {
14
15// contexpr-friendly forwarding
16
17template<typename T>
18constexpr T&& forward(typename std::remove_reference<T>::type& t) noexcept
19{ return static_cast<T&&>(t); }
20
21
22template<typename T>
23constexpr T&& forward(typename std::remove_reference<T>::type&& t) noexcept
24{
25 static_assert(!std::is_lvalue_reference<T>::value, "T must not be an lvalue reference type");
26 return static_cast<T&&>(t);
27}
28
29#if (defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7) || defined(_MSC_VER)
30#define BOOST_HOF_FORWARD(...) boost::hof::forward<__VA_ARGS__>
31#else
32#define BOOST_HOF_FORWARD(...) static_cast<__VA_ARGS__ &&>
33#endif
34
35}} // namespace boost::hof
36
37#endif
38

source code of boost/libs/hof/include/boost/hof/detail/forward.hpp