typeid Questions

4

Solved

I am attempting to do something like: class Base { public: Base() { cout << typeid(*this).name() << endl; } ... }; class Derived : public Base { ... } class MoreDerived : public D...
Haler asked 19/7, 2011 at 12:27

7

Solved

I am wondering what the difference is between typeid and typeof in C++. Here's what I know: typeid is mentioned in the documentation for type_info which is defined in the C++ header file typeinfo...
Caucasoid asked 31/12, 2009 at 17:55

6

Solved

How is it possible to create a recursive variadic template to print out the contents of a paramater pack? I am trying with this, but it fails to compile: template <typename First, typename ...A...
Yawn asked 19/8, 2011 at 17:2

6

Solved

I know that compilers have much freedom in implementing std::type_info functions' behavior. I'm thinking about using it to compare object types, so I'd like to be sure that: std::type_info::name...
Errand asked 16/11, 2010 at 12:39

4

Basically, I want to get typeid(*this).name(), i.e. the real type of this. I want to get this in GDB (without modifying the source code). I tried print typeid(*this) but it says that typeid is unk...
Mervin asked 5/3, 2012 at 14:21

1

I want to specify that a certain type reported by Boost TypeIndex boost::typeindex::type_id<T>().pretty_name() would yield a specific name. The problem I want to solve is that, as reported in...
Destructor asked 5/3, 2017 at 17:13

2

Solved

I am reading the C++11 draft standard and the section on [expr.typeid] mentions the following (emphasis mine): [...] When typeid is applied to an expression other than a glvalue of a polymorp...
Salubrious asked 1/6, 2020 at 14:6

2

Solved

Is it OK to compare the results from two typeid() results? cppreference has this note about this operator: There is no guarantee that the same std::type_info instance will be referred to by all...
Jeffers asked 25/11, 2018 at 13:12

5

Solved

We have a sub-project 'commonUtils' that has many generic code-snippets used across the parent project. One such interesting stuff i saw was :- /***************************************************...
Armagh asked 10/7, 2009 at 6:8

1

Solved

Here is a typical implementation of type_info::operator==: #if _PLATFORM_SUPPORTS_UNIQUE_TYPEINFO bool operator==(const type_info& __rhs) const { return __mangled_name == __rhs.__mangled_nam...
Crispation asked 11/4, 2018 at 11:16

2

Solved

I've migrated from boost::variant to std::variant, and hit a snag. I was using a nice function in boost 'type()' that lets you get the currently held typeid. See https://www.boost.org/doc/libs/1_...
Hasan asked 9/12, 2018 at 21:11

1

Solved

In some cases, see one example below, std::is_floating_point is returning false for float. #include <iostream> #include <type_traits> #include <vector> int main() { ::std::cout...
Wiggle asked 12/9, 2018 at 9:3

1

Solved

I have these classes: (class Question is abstract the others are derived) class Question{ }; class QSingleChoice{ }; class QMultipleChoice{ }; etc. I have a vector<Question*> that store...
Stylography asked 26/5, 2018 at 15:16

1

The problem: I have a family of objects with a common base, and I need to be able to identify the specific concrete type via an integer value. There are two obvious approaches to do that, however...
Kus asked 12/2, 2018 at 16:14

1

Solved

Given the following source code: #include <memory> #include <typeinfo> struct Base { virtual ~Base(); }; struct Derived : Base { }; int main() { std::unique_ptr<Base> ptr_f...
Magdau asked 29/9, 2017 at 18:28

4

Solved

I have a program in which, partly for informational logging, I output the names of some classes as they are used (specifically I add an entry to a log saying along the lines of Messages::CSomeClass...
Nowise asked 29/11, 2011 at 9:46

2

Solved

I just discoverd the following behaviour : having an object of type B derived from type A, the final type during the construction of A is A and not B. This can be observed with the following exampl...
Kilian asked 14/7, 2017 at 13:1

1

Solved

Why following example: #include <iostream> #include <typeinfo> template<typename T> void fun(const T& param) { std::cout << "T = " << typeid(T).name() << ...
Villiers asked 11/12, 2016 at 14:31

4

Solved

In C++11, I am using this typeid(T).name() for my own hash computation. I don't need the result to be same between the program runs or compilations. I just need it to be unique for the types. I ...
Knifeedged asked 1/11, 2016 at 10:10

1

Solved

Compiler: TDM-GCC-5.1.0 (SJLJ unwinding) I was playing around with declval and I noticed that I was unable to use it in a context where it should work: as an argument to typeid(). In the followin...
Stanwinn asked 25/8, 2016 at 22:37

3

Solved

How do i properly identify a type of variable in c++. I tried this to identify a type of variable : int a = 5; std::cout << typeid(a).name() << std::endl; And instead of the expected...
Goldsberry asked 29/4, 2016 at 22:39

2

Solved

The typeid represents a C++ RTTI operator being also a C++ keyword. It returns a std::type_info object that holds (dynamic) type specific information. From what I understood from various sources, ...
Hatband asked 14/11, 2015 at 4:2

3

The format of the output of type_info::name() is implementation specific. namespace N { struct A; } const N::A *a; typeid(a).name(); // returns e.g. "const struct N::A" but compiler-specific ...
Rawden asked 12/12, 2011 at 13:48

4

Solved

In one of the projects I'm working on, I'm seeing this code struct Base { virtual ~Base() { } }; struct ClassX { bool isHoldingDerivedObj() const { return typeid(1 ? *m_basePtr : *m_basePtr) =...
Sabin asked 22/7, 2011 at 20:43

2

Solved

clang doesn't compile the third call to typeid below (see live example). But I can't see anything in §5.2.8 that disallows this, specially when we consider that the expression B::f is not a glvalue...
Fadge asked 20/1, 2015 at 19:30

© 2022 - 2024 — McMap. All rights reserved.