This commit is contained in:
MihailRis
2025-06-28 11:46:10 +03:00
parent f17167f8c9
commit 1c8cafbb68
2 changed files with 73 additions and 66 deletions
+27
View 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;