Skip to content

Commit d160331

Browse files
authored
feat: add reference type traits (#19)
1 parent 5c4e410 commit d160331

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include "tinystl/type_traits/primary_type_categories/is_lvalue_reference.h"
4+
#include "tinystl/type_traits/primary_type_categories/is_rvalue_reference.h"
5+
6+
namespace tinystl {
7+
template<class T>
8+
struct is_reference : bool_constant<is_lvalue_reference<T>::value || is_rvalue_reference<T>::value> {};
9+
10+
template <class T>
11+
inline constexpr bool is_reference_v = is_reference<T>::value;
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include "tinystl/type_traits/helper_classes/integral_constant.h"
4+
5+
namespace tinystl {
6+
template<class T>
7+
struct is_lvalue_reference : false_type {};
8+
template<class T>
9+
struct is_lvalue_reference<T&> : true_type {};
10+
11+
template<class T>
12+
inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<T>::value;
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include "tinystl/type_traits/helper_classes/integral_constant.h"
4+
5+
namespace tinystl {
6+
template<class T>
7+
struct is_rvalue_reference : false_type {};
8+
template<class T>
9+
struct is_rvalue_reference<T&&> : true_type {};
10+
11+
template <class T>
12+
inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<T>::value;
13+
}

0 commit comments

Comments
 (0)