[Boost-bugs] [Boost C++ Libraries] #2768: [any] Unique type_info

Subject: [Boost-bugs] [Boost C++ Libraries] #2768: [any] Unique type_info
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-02-17 17:30:38


#2768: [any] Unique type_info
-----------------------------------------+----------------------------------
 Reporter: nowake_at_[hidden] | Owner: nasonov
     Type: Patches | Status: new
Milestone: Boost 1.39.0 | Component: any
  Version: Boost 1.38.0 | Severity: Optimization
 Keywords: any type_info typeid unique |
-----------------------------------------+----------------------------------
 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)
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2768>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC