1 /*
2  *  Copyright (c) 2016, Facebook, Inc.
3  *  All rights reserved.
4  *
5  *  This source code is licensed under the BSD-style license found in the
6  *  LICENSE file in the root directory of this source tree. An additional grant
7  *  of patent rights can be found in the PATENTS file in the same directory.
8  */
9 
10 #ifndef FATAL_INCLUDE_fatal_type_remove_rvalue_reference_h
11 #define FATAL_INCLUDE_fatal_type_remove_rvalue_reference_h
12 
13 namespace fatal {
14 
15 /**
16  * Removes any r-value references from a given type.
17  * L-value references remain untouched.
18  *
19  * Example:
20  *
21  *  // yields `int`
22  *  using result1 = remove_rvalue_reference<int &&>::type;
23  *
24  *  // yields `int const`
25  *  using result2 = remove_rvalue_reference<int const &&>::type;
26  *
27  *  // yields `int *`
28  *  using result3 = remove_rvalue_reference<int *>::type;
29  *
30  *  // yields `int *&`
31  *  using result4 = remove_rvalue_reference<int *&>::type;
32  *
33  *  // yields `int const &`
34  *  using result5 = remove_rvalue_reference<int const &>::type;
35  *
36  * @author: Marcelo Juchem <marcelo@fb.com>
37  */
38 template <typename T>
39 struct remove_rvalue_reference {
40   using type = T;
41 };
42 
43 template <typename T>
44 struct remove_rvalue_reference<T &&> {
45   using type = T;
46 };
47 
48 template <typename T>
49 using remove_rvalue_reference_t = typename remove_rvalue_reference<T>::type;
50 
51 } // namespace fatal
52 
53 #endif // FATAL_INCLUDE_fatal_type_remove_rvalue_reference_h
54