Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#2768 closed Patches (wontfix)

[any] Unique type_info

Reported by: nowake@… 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)

any.hpp (6.5 KB ) - added by nowake@… 14 years ago.
boost::any that return unique type_info instance

Download all attachments as: .zip

Change History (3)

by nowake@…, 14 years ago

Attachment: any.hpp added

boost::any that return unique type_info instance

comment:1 by anonymous, 13 years ago

Resolution: wontfix
Status: newclosed

comment:2 by nasonov, 13 years ago

Anonymous who closed the bug was me.

Note: See TracTickets for help on using tickets.