When I run the snippet below, it prints out:
int&
int __cdecl(void)
I was expecting the second line to just be int
Why is this happening? What could I do to fix it if it were inside a templated function that takes pointers or iterators so I couldn't use std::remove_pointer
.
#include <type_traits>
#include <iostream>
int main()
{
int r = 4;
int* rp = &r;
using return_type = decltype(*rp);
using no_ref_type = std::remove_reference<return_type>::type();
std::cout << typeid(return_type).name() << '&' << std::endl;
std::cout << typeid(no_ref_type).name();
}