-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathis_const.cpp
More file actions
20 lines (17 loc) · 724 Bytes
/
is_const.cpp
File metadata and controls
20 lines (17 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <type_traits>
struct Data
{
char __bytes[255];
};
static void function()
{
const Data value { };
const Data& dataRef = value;
static_assert(std::is_same<decltype(dataRef), const Data&>::value);
// std::is_const<> to reference types always returns false as we can't qualify a reference type as 'const'
// NOTE: std::is_const<> tells whether the type is const qualified or not, it doesn't tell the intrinsic constness!
static_assert(std::is_const<decltype(dataRef)>::value); // it fails here
// Also
// std::is_const<const int*>::value or std::is_const<int const*>::value would evaluate to false
// And std::is_const<int * const>::value or std::is_const<const int* const>::value would evaluate to true
}