|
Boost.PythonHeader <boost/python/type_id.hpp> |
type_info
type_info
synopsis
type_info
constructor
type_info
comparison functions
type_info
observer functions
<boost/python/type_id.hpp>
provides types and
functions for runtime type identification like those of of
<typeinfo>
. It exists mostly to work around
certain compiler bugs and platform-dependent interactions with
shared libraries.
type_info
type_info
instances identify a type. As
std::type_info
is specified to (but unlike its
implementation in some compilers),
boost::python::type_info
never represents top-level
references or cv-qualification (see section 5.2.8 in the C++
standard). Unlike std::type_info
,
boost::python::type_info
instances are copyable, and
comparisons always work reliably across shared library boundaries.
namespace boost { namespace python { class type_info : totally_ordered<type_info> { public: // constructor type_info(std::type_info const& = typeid(void)); // comparisons bool operator<(type_info const& rhs) const; bool operator==(type_info const& rhs) const; // observers char const* name() const; }; }}
type_info
constructortype_info(std::type_info const& = typeid(void));
type_info
object
which identifies the same type as its argument.
type_info
objects a benign default
argument is supplied. Note: this
constructor does not correct for non-conformance of
compiler typeid()
implementations. See type_id
, below.
type_info
comparisonsbool operator<(type_info const& rhs) const;
type_info
objects.
bool operator==(type_info const& rhs) const;
true
iff the two values describe
the same type.
totally_ordered<type_info>
as a private base class supplies operators <=
,
>=
, >
, and !=
type_info
observerschar const* name() const;
name()
on
the argument used to construct the object.
std::ostream& operator<<(std::ostream&s, type_info const&x);
x
into s
.
type_info::name()
string, but
for some we may be able to decode the string and produce a
reasonable representation.
template <class T> type_info type_id()
type_info(typeid(T))
type_id
facility might be used
#include <boost/python/type_id.hpp> // Returns true iff the user passes an int argument template <class T> bool is_int(T x) { using boost::python::type_id; return type_id<T>() == type_id<int>(); }
Revised 13 November, 2002
© Copyright Dave Abrahams 2002. All Rights Reserved.