-
Notifications
You must be signed in to change notification settings - Fork 6
/
as_const.hpp
45 lines (33 loc) · 887 Bytes
/
as_const.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @file as_const.hpp
* @brief
* @date 2020-01-18
* @author Peter
* @copyright
* Peter of [ThinkSpirit Laboratory](http://thinkspirit.org/)
* of [Nanjing University of Information Science & Technology](http://www.nuist.edu.cn/)
* all rights reserved
*/
#ifndef KERBAL_UTILITY_AS_CONST_HPP
#define KERBAL_UTILITY_AS_CONST_HPP
#include <kerbal/compatibility/constexpr.hpp>
#include <kerbal/compatibility/noexcept.hpp>
#include <kerbal/type_traits/add_const.hpp>
namespace kerbal
{
namespace utility
{
template <typename T>
KERBAL_CONSTEXPR
typename kerbal::type_traits::add_const<T>::type &
as_const(T & ref) KERBAL_NOEXCEPT
{
return ref;
}
# if __cplusplus >= 201103L
template <typename T>
void as_const(const T &&) = delete;
# endif
} // namespace utility
} // namespace kerbal
#endif // KERBAL_UTILITY_AS_CONST_HPP