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...
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...
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...
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...
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...
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...
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...
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...
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() << ...
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 ...
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...
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...
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, ...
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
...
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
1 Next >
© 2022 - 2024 — McMap. All rights reserved.