mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
refactor
This commit is contained in:
parent
f17167f8c9
commit
1c8cafbb68
2 changed files with 73 additions and 66 deletions
27
src/util/type_helpers.hpp
Normal file
27
src/util/type_helpers.hpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
template <typename T>
|
||||
struct remove_const_ref_if_primitive {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct remove_const_ref_if_primitive<const T&> {
|
||||
using stripped_type = typename std::remove_const<typename std::remove_reference<T>::type>::type;
|
||||
using type = typename std::conditional<std::is_fundamental<stripped_type>::value,
|
||||
stripped_type,
|
||||
const T&>::type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct remove_const_ref_if_primitive<const T> {
|
||||
using stripped_type = typename std::remove_const<T>::type;
|
||||
using type = typename std::conditional<std::is_fundamental<stripped_type>::value,
|
||||
stripped_type,
|
||||
const T>::type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using remove_const_ref_if_primitive_t = typename remove_const_ref_if_primitive<T>::type;
|
||||
Loading…
Add table
Add a link
Reference in a new issue