forked from boostorg/type_index
Updated docs and fixed some issues
This commit is contained in:
1 parent
8ab45702a0
commit
d0d30d56df
5 files changed
+50
-53
No files matched your search
@@ -8,7 +8,7 @@
|
||||
#ifndef BOOST_TYPE_INDEX_HPP
|
||||
#define BOOST_TYPE_INDEX_HPP
|
||||
|
||||
/// \file type_index.hpp
|
||||
/// \file boost/type_index.hpp
|
||||
/// \brief Includes all the headers of the Boost.TypeIndex library.
|
||||
///
|
||||
/// By inclusion of this file all classes (boost::type_info + boost::type_index if RTTI is on
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/// \file type_index.hpp
|
||||
/// \file boost/type_index/type_index.hpp
|
||||
/// \brief Contains implementation of boost::type_index class.
|
||||
///
|
||||
/// boost::type_index class is used in situations when RTTI is enabled.
|
||||
/// When RTTI is disabled boost::template_index will be used instead of
|
||||
/// this class.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_index/type_info.hpp>
|
||||
@@ -33,12 +35,16 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
/// Copyable type_index class that requires RTTI.
|
||||
/// Copyable std::type_index class that requires RTTI.
|
||||
/// When RTTI is disabled boost::template_index will be used instead of
|
||||
/// this class.
|
||||
class type_index {
|
||||
private:
|
||||
const type_info* pinfo_;
|
||||
|
||||
public:
|
||||
typedef detail::stl_type_info stl_type_info;
|
||||
|
||||
/// Default constructor.
|
||||
type_index() BOOST_NOEXCEPT
|
||||
: pinfo_(static_cast<const type_info*>(&typeid(void)))
|
||||
@@ -50,7 +56,7 @@ public:
|
||||
{}
|
||||
|
||||
/// Constructs type_index from an instance of std::type_info.
|
||||
type_index(const detail::stl_type_info& inf) BOOST_NOEXCEPT
|
||||
type_index(const stl_type_info& inf) BOOST_NOEXCEPT
|
||||
: pinfo_(static_cast<const type_info*>(&inf))
|
||||
{}
|
||||
|
||||
@@ -70,7 +76,6 @@ public:
|
||||
return pinfo_->name_demangled();
|
||||
}
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
bool operator == (type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return *pinfo_ == *rhs.pinfo_;
|
||||
}
|
||||
@@ -96,30 +101,30 @@ public:
|
||||
}
|
||||
|
||||
|
||||
bool operator == (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator == (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this == type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator != (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator != (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this != type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator < (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator < (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this < type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator > (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator > (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this > type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator <= (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator <= (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this <= type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator >= (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator >= (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this >= type_index(rhs);
|
||||
}
|
||||
#endif // BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
|
||||
|
||||
/// Function for getting hash value
|
||||
std::size_t hash_code() const BOOST_NOEXCEPT {
|
||||
@@ -127,8 +132,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
|
||||
/* *************** type_index free functions ******************* */
|
||||
|
||||
inline bool operator == (detail::stl_type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT {
|
||||
@@ -155,18 +158,12 @@ inline bool operator >= (detail::stl_type_info const& lhs, type_index const& rhs
|
||||
return rhs <= lhs;
|
||||
}
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
|
||||
#ifdef BOOST_CLASSINFO_COMPARE_BY_NAMES
|
||||
#undef BOOST_CLASSINFO_COMPARE_BY_NAMES
|
||||
#endif
|
||||
|
||||
/// @endcond
|
||||
|
||||
/* *************** type_index free functions ******************* */
|
||||
|
||||
/// @cond
|
||||
|
||||
#ifndef BOOST_NO_IOSTREAM
|
||||
#ifdef BOOST_NO_TEMPLATED_IOSTREAMS
|
||||
|
||||
@@ -193,8 +190,6 @@ inline std::size_t hash_value(type_index const& v) BOOST_NOEXCEPT {
|
||||
return v.hash_code();
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#else // !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)
|
||||
|
||||
@@ -51,11 +51,10 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
/// @cond
|
||||
|
||||
// for this compiler at least, cross-shared-library type_info
|
||||
// comparisons don't work, so use typeid(x).name() instead. It's not
|
||||
// yet clear what the best default strategy is.
|
||||
// comparisons don't work, so we are using typeid(x).name() instead.
|
||||
# if (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5))) \
|
||||
|| defined(_AIX) \
|
||||
|| (defined(__sgi) && defined(__host_mips)) \
|
||||
@@ -64,7 +63,7 @@ namespace boost {
|
||||
# define BOOST_CLASSINFO_COMPARE_BY_NAMES
|
||||
# endif
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
/// @endcond
|
||||
|
||||
namespace detail {
|
||||
#ifdef BOOST_NO_STD_TYPEINFO
|
||||
@@ -88,6 +87,8 @@ namespace detail {
|
||||
/// * workarounds some cimpiler issues
|
||||
class type_info: public detail::stl_type_info {
|
||||
public:
|
||||
typedef detail::stl_type_info stl_type_info;
|
||||
|
||||
/// Factory method for constructing boost::type_info instance for type T.
|
||||
/// Strips const, volatile and & modifiers from T.
|
||||
template <class T>
|
||||
@@ -135,18 +136,19 @@ public:
|
||||
return static_cast<const boost::type_info&>(typeid(rtti_val));
|
||||
}
|
||||
|
||||
/// Returns mangled type name.
|
||||
const char* name() const BOOST_NOEXCEPT {
|
||||
#ifdef _MSC_VER
|
||||
return detail::stl_type_info::raw_name();
|
||||
return stl_type_info::raw_name();
|
||||
#else
|
||||
return detail::stl_type_info::name();
|
||||
return stl_type_info::name();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Returns user-friendly name
|
||||
std::string name_demangled() const {
|
||||
#if defined(_MSC_VER)
|
||||
std::string ret = detail::stl_type_info::name();
|
||||
std::string ret = stl_type_info::name();
|
||||
#else
|
||||
std::string ret;
|
||||
int status = 0;
|
||||
@@ -184,7 +186,7 @@ public:
|
||||
#ifdef BOOST_CLASSINFO_COMPARE_BY_NAMES
|
||||
return !std::strcmp(name(), rhs.name());
|
||||
#else
|
||||
return static_cast<const detail::stl_type_info&>(*this) == static_cast<const detail::stl_type_info&>(rhs);
|
||||
return static_cast<const stl_type_info&>(*this) == static_cast<const stl_type_info&>(rhs);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -192,32 +194,36 @@ public:
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
bool operator == (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator == (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this == static_cast<const boost::type_info&>(rhs);
|
||||
}
|
||||
|
||||
bool operator != (detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
bool operator != (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
/// Returns true if the type precedes the type of rhs in the collation order.
|
||||
/// The collation order is just an internal order.
|
||||
/// Works exactly like operator <
|
||||
bool before(type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
#ifdef BOOST_CLASSINFO_COMPARE_BY_NAMES
|
||||
return std::strcmp(name(), rhs.name()) < 0;
|
||||
#else
|
||||
return detail::stl_type_info::before(rhs);
|
||||
return stl_type_info::before(rhs);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool before(detail::stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
/// Returns true if the type precedes the type of rhs in the collation order.
|
||||
/// The collation order is just an internal order.
|
||||
/// Works exactly like operator <
|
||||
bool before(stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return before(static_cast<const boost::type_info&>(rhs));
|
||||
}
|
||||
|
||||
/// Function for getting hash value
|
||||
std::size_t hash_code() const BOOST_NOEXCEPT {
|
||||
#if _MSC_VER >= 1600 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5 && defined(__GXX_EXPERIMENTAL_CXX0X__))
|
||||
return detail::stl_type_info::hash_code();
|
||||
return stl_type_info::hash_code();
|
||||
#else
|
||||
return boost::hash_range(name(), name() + std::strlen(name()));
|
||||
#endif
|
||||
@@ -228,7 +234,8 @@ public:
|
||||
#undef BOOST_CLASSINFO_COMPARE_BY_NAMES
|
||||
#endif
|
||||
|
||||
/// Function, to get std::type_info for a type T. Strips const, volatile and & modifiers from T.
|
||||
/// Function to get std::type_info for a type T.
|
||||
/// Strips const, volatile and & modifiers from T.
|
||||
template <class T>
|
||||
inline const type_info& type_id() BOOST_NOEXCEPT {
|
||||
return type_info::construct<T>();
|
||||
@@ -243,7 +250,7 @@ inline const type_info& type_id_with_cvr() BOOST_NOEXCEPT {
|
||||
return type_info::construct_with_cvr<T>();
|
||||
}
|
||||
|
||||
/// Function, that works exactly like C++ typeid(rtti_val) call, but returns boost::type_info.
|
||||
/// Function that works exactly like C++ typeid(rtti_val) call, but returns boost::type_info.
|
||||
/// This method available only with RTTI enabled. Without RTTI support it won't compile,
|
||||
/// producing a compile-time error with message: "boost::type_id_rtti_only(T&) requires RTTI"
|
||||
template <class T>
|
||||
@@ -251,7 +258,7 @@ inline const type_info& type_id_rtti_only(T& rtti_val) BOOST_NOEXCEPT {
|
||||
return static_cast<const type_info&>(typeid(rtti_val));
|
||||
}
|
||||
|
||||
/// Function, that works exactly like C++ typeid(rtti_val) call, but returns boost::type_info.
|
||||
/// Function that works exactly like C++ typeid(rtti_val) call, but returns boost::type_info.
|
||||
/// This method available only with RTTI enabled. Without RTTI support it won't compile,
|
||||
/// producing a compile-time error with message: "boost::type_id_rtti_only(T*) requires RTTI"
|
||||
template <class T>
|
||||
|
||||
Reference in new issue
Block a user