#2768 closed Patches (wontfix)
[any] Unique type_info
| Reported by: | Owned by: | nasonov | |
|---|---|---|---|
| Milestone: | Boost 1.39.0 | Component: | any |
| Version: | Boost 1.38.0 | Severity: | Optimization |
| Keywords: | any type_info typeid unique | Cc: |
Description
Because typeid() does not return unique instance, we cannot use type_info instance pointer to compare types. And we cannot use type_info pointer with unorderd_*.
# unorderd_map is useful to implement boost::any's multi method (visitor) to dispatch in constant-time.
So I use static local variable in a function (like Singleton technique) to access type's type_info like this.
namespace boost {
class any {
(snip)
template<typename ValueType>
static const std::type_info& any::typeinfo()
{
static const std::type_info& r(typeid(ValueType));
return r;
}
const std::type_info & type() const
{
//return content ? content->type() : typeid(void);
return content ? content->type() : typeinfo<void>();
}
(snip)
template<typename ValueType>
class holder : public placeholder {
(snip)
virtual const std::type_info & type() const {
//return typeid(ValueType);
return typeinfo<ValueType>();
}
(snip)
Attachments (1)
Change History (3)
by , 14 years ago
comment:1 by , 13 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

boost::any that return unique type_info instance