#include <iostream>
#include <memory>
#include <typeinfo> // for typeid
struct Foo
{
Foo(int in) : a(in) {}
void print() const
{
std::cout << "a = " << a << '\n';
}
int a;
};
int main()
{
auto ptr = std::make_shared<Foo>(10);
ptr->print();
(*ptr).print();
std::cout << typeid(*ptr).name() << std::endl;
int a = 100;
std::cout << typeid(a).name()<< std::endl;
std::cout << std::boolalpha << std::is_same_v<decltype(a),int> << std::endl; // is_same_v from cpp17
std::cout << std::boolalpha << std::is_same<decltype(a), float>::value << std::endl; // since cpp 11
}
reference:
https://en.cppreference.com/w/cpp/types/is_same