Boost logo

Boost :

Subject: Re: [boost] [TypeIndex] Peer review period for library acceptance begins, ending Thurs 21st Nov
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2013-11-16 10:58:16


2013/11/16 Mathieu Champlon <m.champlon_at_[hidden]>
<...>

> Do you think getting the type info of the "current" type of a variable (as
> opposed to it's real type) could sometimes prove useful ?
> Could it be worth adding a function in TypeIndex ?
>

This is a very very common use case in Boost and widely used technique in
libraries that use type erasure. Examples are Boost.Function, Boost.Any,
Boost,Graph, Boost.Math and others...
Such function is already in TypeIndex library, see boost::type_info<T>().

Also using a local type as a template argument is illegal in C++03 (not in
> C++11 any more).
> For instance :
>
> void f()
> {
> struct s {};
> boost::type_id< s >(); // illegal in C++03
> typeid( s ); // legal
> }
>
> Maybe it should be stated in the documentation as this is an area where
> boost::type_id is not a drop-in replacement for typeid (in C++03) ?
>

Neat example, but I don't think that this must be mentioned in TypeIndex
docs. This is a C++03 related restriction and a rare use case, so it will
just complicate the docs.

-- 
Best regards,
Antony Polukhin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk