• Joseph

Type Manipulation in C++

C++ standard library has simple functions to manipulate types. The following example shows how we can find the type of a variable and create new types using that.


int main() { const double A = 10; using A_type = decltype(A); // find the type of variable A using A_ptr_type = std::add_pointer<A_type>::type; // A_ptr_type will be double * A_ptr_type A_ptr = &A; using B_type = std::remove_pointer<decltype(A_ptr)>::type; // B_type will be double B_type B = 2.0; }







2 views0 comments

Recent Posts

See All