I want to add const to a reference type by typedef const A B;.
Somehow it doesn't work. Is this not possible in c++?
Test:
#include <type_traits> typedef int& A; typedef const A B; // <-- Add const // typedef std::add_const<A>::type B; // also doesn't work. static_assert(std::is_const<typename std::remove_reference< B>::type>::value, "is const"); int main() { return 0; } Compilation Error:
add2.cpp:5:1: error: static assertion failed: is const static_assert(std::is_const<typename std::remove_reference< ^~~~~~~~~~~~~