Closed Lastique closed 1 year ago
Actually, there are problems with typeid
besides the incomplete types, see here, for example. Looks like boost::core::type_name()
is broken for member function types as well.
Why do we need boost::core::type_name
again? I thought demangle
would be enough.
Looks like typeid
doesn't work on qualified member functions, but only under C++03 and for Clang after 10.
See https://godbolt.org/z/M5s348jxf for example. Under MSVC, it also cleans up things like struct X
, __cdecl
, __ptr64
and other cruft.
See https://godbolt.org/z/M5s348jxf for example. Under MSVC, it also cleans up things like
struct X
,__cdecl
,__ptr64
and other cruft.
This could be achieved by string modification instead of decomposing types and generating type_info
structures for each component.
Both cases should be fixed on develop.
This could be achieved by string modification instead of decomposing types and generating type_info structures for each component.
Maybe... but I don't think it would be particularly easy. There are a lot of other weird differences between the demangled typeid(T).name()
such as whitespace placement, []
being [0]
, unsigned long long
being unsigned __int64
, etc, and figuring out std::map<std::string, std::string>
would basically require parsing the string back into a type structure, or doing creative things with regex capture matching. type_name
takes care of all that. It also works with -fno-rtti and can do slightly better than just giving up.
In addition, there are odd cases where typeid(T).name()
doesn't work, such as incomplete types (fixed now thanks to you) and e.g. std::pair<void, void>
.
All this is admittedly overkill for the purposes of BOOST_TEST_TRAIT, looking at its output was just what motivated me to write type_name
.
Both cases should be fixed on develop.
Thank you. Although I have already switched to BOOST_TEST
in these test cases.
Here's an example:
The test intentionally uses an incomplete type to test the trait's behavior wrt. incomplete types.