Boost logo

Boost Users :

Subject: [Boost-users] [type_erasure] use of typeid_of with reference any
From: Joaquin M López Muñoz (joaquinlopezmunoz_at_[hidden])
Date: 2016-08-21 13:22:01


Boost.TypeErasure docs say

   template<typename Concept, typename T>
     const std::type_info & typeid_of(const any< Concept, T > & arg);

   [...]

   Requires: Concept includes typeid_<T>. T is a non-reference,
CV-unqualified placeholder.

which, if my literal reading is right, means that you can't use
typeid_of on, say,
any<typeid_<>,_self&>, yet the following compiles on GCC

     #include <boost/type_erasure/any.hpp>
     #include <boost/type_erasure/builtin.hpp>
     #include <boost/type_erasure/typeid_of.hpp>
     #include <iostream>

     using namespace boost::type_erasure;

     int main()
     {
       int x=0;
any<boost::mpl::vector<typeid_<>,relaxed>,_self&> a=x;
       std::cout<<typeid_of(a).name()<<"\n";
     }

and correctly outputs the name of the "int" type. Is this a bug in the
docs or am I
missing something?

Thank you,

Joaquín M López Muñoz


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net