forked from boostorg/type_index
Removed old unused files
This commit is contained in:
@ -1,35 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Antony Polukhin, 2012-2013.
|
||||
//
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_TEMPLATE_INDEX_HPP
|
||||
#define BOOST_TYPE_INDEX_TEMPLATE_INDEX_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
|
||||
/// \file template_index.hpp
|
||||
/// \brief Contains implementation of boost::template_index class.
|
||||
///
|
||||
/// boost::template_index is just a typedef of boost::template_info, that combines functionality
|
||||
/// of boost::type_info and boost::type_index but can work with RTTI disabled.
|
||||
|
||||
#include <boost/type_index/template_info.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
/// boost::template_index is just a typedef of boost::template_info, that combines functionality
|
||||
/// of boost::type_info and boost::type_index but can work with RTTI disabled.
|
||||
typedef template_info template_index;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_TEMPLATE_INDEX_HPP
|
||||
|
@ -1,317 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Antony Polukhin, 2012-2013.
|
||||
//
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_TEMPLATE_INFO_HPP
|
||||
#define BOOST_TYPE_INDEX_TEMPLATE_INFO_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
|
||||
/// \file template_info.hpp
|
||||
/// \brief Contains implementation of boost::template_info class.
|
||||
///
|
||||
/// boost::template_info class is used instead of boost::type_info and boost::type_index classes
|
||||
/// in situations when RTTI is disabled.
|
||||
///
|
||||
/// It combines functionality of std::type_info and std::type_index.
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
#if !defined(BOOST_NO_IOSFWD)
|
||||
#include <iosfwd> // for std::basic_ostream
|
||||
#else
|
||||
#include <ostream>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_FUNCTION_SIGNATURE
|
||||
/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE is used by boost::template_info class to
|
||||
/// deduce the name of a template parameter. If your compiler is not recognized
|
||||
/// by the TypeIndex library and you wish to work with boost::template_info, you may
|
||||
/// define this macro by yourself.
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE must be defined to a compiler specific macro,
|
||||
/// that outputs the WHOLE function signature, including template parameters.
|
||||
///
|
||||
/// If your compiler is not recognised and BOOST_TYPE_INDEX_FUNCTION_SIGNATURE is not defined,
|
||||
/// then a compile-time error will arise at any attempt to use boost::template_info or
|
||||
/// boost::template_index classes.
|
||||
#define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE BOOST_CURRENT_FUNCTION
|
||||
|
||||
#elif defined(BOOST_TYPE_INDEX_FUNCTION_SIGNATURE)
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert(){}
|
||||
|
||||
#elif defined(__FUNCSIG__)
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert(){}
|
||||
#define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE __FUNCSIG__
|
||||
|
||||
#elif defined(__PRETTY_FUNCTION__) \
|
||||
|| defined(__GNUC__) \
|
||||
|| (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \
|
||||
|| (defined(__ICC) && (__ICC >= 600)) \
|
||||
|| defined(__ghs__) \
|
||||
|| defined(__DMC__)
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert(){}
|
||||
#define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE __PRETTY_FUNCTION__
|
||||
|
||||
#else
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert() {
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
sizeof(T) && false,
|
||||
"TypeIndex library could not detect your compiler. "
|
||||
"Please make the BOOST_TYPE_INDEX_FUNCTION_SIGNATURE macro use "
|
||||
"correct compiler macro for getting the whole function name. "
|
||||
"Do not forget to also define BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP and "
|
||||
"BOOST_TYPE_INDEX_CTTI_END_SKIP."
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE, BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP
|
||||
/// and BOOST_TYPE_INDEX_CTTI_END_SKIP macroses are used for adding a
|
||||
/// support for compilers, that by default are not recognized by TypeIndex library.
|
||||
///
|
||||
/// See Compiler support for more info
|
||||
#define BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP 0
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_CTTI_END_SKIP
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE, BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP
|
||||
/// and BOOST_TYPE_INDEX_CTTI_END_SKIP macroses are used for adding a
|
||||
/// support for compilers, that by default are not recognized by TypeIndex library.
|
||||
///
|
||||
/// See Compiler support for more info
|
||||
#define BOOST_TYPE_INDEX_CTTI_END_SKIP 0
|
||||
|
||||
#elif defined(BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP) && defined(BOOST_TYPE_INDEX_CTTI_END_SKIP)
|
||||
// skip user specified bytes count
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_begin = BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP);
|
||||
// skip user specified bytes count
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_end = BOOST_TYPE_INDEX_CTTI_END_SKIP);
|
||||
#elif defined _MSC_VER
|
||||
// sizeof("const char *__cdecl boost::detail::ctti<") - 1
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_begin = 40);
|
||||
|
||||
// sizeof(">::n(void)") - 1
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_end = 10);
|
||||
|
||||
#elif defined __clang__
|
||||
// sizeof("static const char *boost::detail::ctti<") - 1
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_begin = 39);
|
||||
|
||||
// == sizeof(">::n()") - 1
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_end = 6);
|
||||
#elif defined __GNUC__
|
||||
// sizeof("static const char* boost::detail::ctti<T>::n() [with T = ") - 1
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_begin = 57);
|
||||
|
||||
// == sizeof("]") - 1
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_end = 1);
|
||||
|
||||
#else
|
||||
// TODO: Code for other platforms
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_begin = 0); // skip nothing
|
||||
BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_end = 0); // skip nothing
|
||||
#endif
|
||||
|
||||
/// Noncopyable type_info that does not require RTTI
|
||||
/// CTTI == Compile Time Type Info
|
||||
/// This name must be as short as posible, to avoid code bloat
|
||||
template <class T>
|
||||
struct ctti {
|
||||
typedef T template_type;
|
||||
typedef ctti this_type;
|
||||
|
||||
/// Returns raw name. Must be as short, as possible, to avoid code bloat
|
||||
static const char* n() BOOST_NOEXCEPT {
|
||||
lazy_function_signature_assert<T>();
|
||||
return BOOST_TYPE_INDEX_FUNCTION_SIGNATURE + detail::ctti_skip_size_at_begin;
|
||||
}
|
||||
|
||||
/// Returns raw name
|
||||
static const char* name() BOOST_NOEXCEPT {
|
||||
return this_type::n();
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
/// Copyable type_info class that does not require RTTI.
|
||||
/// When RTTI is disabled this class will be used instead of boost::type_info and boost::type_index.
|
||||
class template_info {
|
||||
private:
|
||||
const char* name_;
|
||||
|
||||
/// @cond
|
||||
explicit template_info(const char* name) BOOST_NOEXCEPT
|
||||
: name_(name)
|
||||
{}
|
||||
/// @endcond
|
||||
|
||||
public:
|
||||
/// Default constructor.
|
||||
template_info() BOOST_NOEXCEPT
|
||||
: name_(detail::ctti<void>::name())
|
||||
{}
|
||||
|
||||
/// Factory method for constructing boost::template_info instance for type T.
|
||||
/// Strips const, volatile and & modifiers from T.
|
||||
///
|
||||
/// Works exactly like boost::template_id().
|
||||
template <class T>
|
||||
static const template_info& construct(){
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::remove_reference<T>::type no_ref_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::remove_cv<no_ref_t>::type no_cvr_t;
|
||||
|
||||
# if (defined(__EDG_VERSION__) && __EDG_VERSION__ < 245) \
|
||||
|| (defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 744)
|
||||
BOOST_STATIC_ASSERT_MSG( !boost::is_arithmetic<no_cvr_t>::type::value
|
||||
, "Your EDG-based compiler seems to mistakenly distinguish 'int' from 'signed int', in typeid() expressions.");
|
||||
#endif
|
||||
|
||||
static const template_info ret(detail::ctti<no_cvr_t>::name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Factory method for constructing template_info instance for type T.
|
||||
/// Does not strip const, volatile and & modifiers from T.
|
||||
///
|
||||
/// Works exactly like boost::template_id_with_cvr().
|
||||
template <class T>
|
||||
static const template_info& construct_with_cvr() {
|
||||
# if (defined(__EDG_VERSION__) && __EDG_VERSION__ < 245) \
|
||||
|| (defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 744)
|
||||
BOOST_STATIC_ASSERT_MSG( !boost::is_arithmetic<T>::type::value
|
||||
, "Your EDG-based compiler seems to mistakenly distinguish 'int' from 'signed int', in typeid() expressions.");
|
||||
#endif
|
||||
|
||||
static const template_info ret(detail::ctti<T>::name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/// Returns true if the type precedes the type of rhs in the collation order.
|
||||
/// The collation order is just an internal order.
|
||||
bool before(const template_info& rhs) const BOOST_NOEXCEPT {
|
||||
return std::strcmp(name(), rhs.name()) < 0;
|
||||
}
|
||||
|
||||
/// Returns raw name
|
||||
const char* name() const BOOST_NOEXCEPT {
|
||||
return name_;
|
||||
}
|
||||
|
||||
/// Returns user-friendly name
|
||||
std::string name_demangled() const {
|
||||
std::size_t len = std::strlen(name_ + detail::ctti_skip_size_at_end);
|
||||
while (name_[len - 1] == ' ') --len; // MSVC sometimes adds whitespaces
|
||||
return std::string(name_, len);
|
||||
}
|
||||
|
||||
bool operator == (const template_info& rhs) const BOOST_NOEXCEPT {
|
||||
return name_ == rhs.name() || !std::strcmp(name_, rhs.name());
|
||||
}
|
||||
|
||||
bool operator != (const template_info& rhs) const BOOST_NOEXCEPT {
|
||||
return name_ != rhs.name() && !!std::strcmp(name_, rhs.name());
|
||||
}
|
||||
|
||||
bool operator < (const template_info& rhs) const BOOST_NOEXCEPT {
|
||||
return name_ != rhs.name() && std::strcmp(name_, rhs.name()) < 0;
|
||||
}
|
||||
|
||||
bool operator > (const template_info& rhs) const BOOST_NOEXCEPT {
|
||||
return name_ != rhs.name() && std::strcmp(name_, rhs.name()) > 0;
|
||||
}
|
||||
|
||||
bool operator <= (const template_info& rhs) const BOOST_NOEXCEPT {
|
||||
return name_ == rhs.name() || std::strcmp(name_, rhs.name()) <= 0;
|
||||
}
|
||||
|
||||
bool operator >= (const template_info& rhs) const BOOST_NOEXCEPT {
|
||||
return name_ == rhs.name() || std::strcmp(name_, rhs.name()) >= 0;
|
||||
}
|
||||
|
||||
/// Function for getting hash value
|
||||
std::size_t hash_code() const BOOST_NOEXCEPT {
|
||||
return boost::hash_range(name_, name_ + std::strlen(name_ + detail::ctti_skip_size_at_end));
|
||||
}
|
||||
};
|
||||
|
||||
/// Method for constructing template_info instance for type T.
|
||||
/// Strips const, volatile and & modifiers from T.
|
||||
template <class T>
|
||||
inline const template_info& template_id() BOOST_NOEXCEPT {
|
||||
return template_info::construct<T>();
|
||||
}
|
||||
|
||||
/// Method for constructing template_info instance for type T.
|
||||
/// Does not strip const, volatile and & modifiers from T.
|
||||
/// If T has no const, volatile, & and && modifiers, then returns exactly
|
||||
/// the same result as in case of calling `template_id<T>()`.
|
||||
template <class T>
|
||||
inline const template_info& template_id_with_cvr() BOOST_NOEXCEPT {
|
||||
return template_info::construct_with_cvr<T>();
|
||||
}
|
||||
|
||||
/* *************** template_info free functions ******************* */
|
||||
|
||||
#ifndef BOOST_NO_IOSTREAM
|
||||
#ifdef BOOST_NO_TEMPLATED_IOSTREAMS
|
||||
/// Ostream operator that will output demangled name
|
||||
inline std::ostream& operator<<(std::ostream& ostr, template_info const& ind) {
|
||||
ostr << ind.name_demangled();
|
||||
return ostr;
|
||||
}
|
||||
#else
|
||||
/// Ostream operator that will output demangled name
|
||||
template <class CharT, class TriatT>
|
||||
inline std::basic_ostream<CharT, TriatT>& operator<<(std::basic_ostream<CharT, TriatT>& ostr, template_info const& ind) {
|
||||
ostr << ind.name_demangled();
|
||||
return ostr;
|
||||
}
|
||||
#endif // BOOST_NO_TEMPLATED_IOSTREAMS
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
|
||||
/// hash_value function overload for template_info
|
||||
inline std::size_t hash_value(template_info const& v) BOOST_NOEXCEPT {
|
||||
return v.hash_code();
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_TEMPLATE_INFO_HPP
|
||||
|
@ -1,221 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_TYPE_INDEX_HPP
|
||||
#define BOOST_TYPE_INDEX_TYPE_INDEX_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/// \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, it is designed to be a drop-in
|
||||
/// replacement for C++11 std::type_index class.
|
||||
///
|
||||
/// When RTTI is disabled boost::template_index will be usually (some compilers allow calling typeid(T)
|
||||
/// even if RTTI is disabled) used instead of this class.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_index/type_info.hpp>
|
||||
|
||||
// MSVC is capable of calling typeid(T) even when RTTI is off
|
||||
#if (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
#if !defined(BOOST_NO_IOSFWD)
|
||||
#include <iosfwd> // for std::basic_ostream
|
||||
#else
|
||||
#include <ostream>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
/// This class is designed to be a drop-in replacement for C++11 std::type_index class.
|
||||
///
|
||||
/// 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)))
|
||||
{}
|
||||
|
||||
/// Constructs type_index from an instance of boost::type_info.
|
||||
type_index(const type_info& inf) BOOST_NOEXCEPT
|
||||
: pinfo_(&inf)
|
||||
{}
|
||||
|
||||
/// Constructs type_index from an instance of std::type_info.
|
||||
type_index(const stl_type_info& inf) BOOST_NOEXCEPT
|
||||
: pinfo_(static_cast<const type_info*>(&inf))
|
||||
{}
|
||||
|
||||
/// Returns true if the type precedes the type of rhs in the collation order.
|
||||
/// The collation order is just an internal order.
|
||||
bool before(type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return pinfo_->before(*rhs.pinfo_);
|
||||
}
|
||||
|
||||
/// Returns raw name
|
||||
const char* name() const BOOST_NOEXCEPT {
|
||||
return pinfo_->name();
|
||||
}
|
||||
|
||||
/// Returns user-friendly name
|
||||
std::string name_demangled() const {
|
||||
return pinfo_->name_demangled();
|
||||
}
|
||||
|
||||
bool operator == (type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return *pinfo_ == *rhs.pinfo_;
|
||||
}
|
||||
|
||||
bool operator != (type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return !(*pinfo_ == *rhs.pinfo_);
|
||||
}
|
||||
|
||||
bool operator < (type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return before(rhs);
|
||||
}
|
||||
|
||||
bool operator > (type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return (rhs < *this);
|
||||
}
|
||||
|
||||
bool operator <= (type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
bool operator >= (type_index const& rhs) const BOOST_NOEXCEPT {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
|
||||
bool operator == (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this == type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator != (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this != type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator < (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this < type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator > (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this > type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator <= (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this <= type_index(rhs);
|
||||
}
|
||||
|
||||
bool operator >= (stl_type_info const& rhs) const BOOST_NOEXCEPT {
|
||||
return *this >= type_index(rhs);
|
||||
}
|
||||
|
||||
|
||||
/// Function for getting hash value
|
||||
std::size_t hash_code() const BOOST_NOEXCEPT {
|
||||
return pinfo_->hash_code();
|
||||
}
|
||||
};
|
||||
|
||||
/* *************** type_index free functions ******************* */
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
|
||||
inline bool operator == (detail::stl_type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT {
|
||||
return rhs == lhs; // Operation is commutative
|
||||
}
|
||||
|
||||
inline bool operator != (detail::stl_type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT {
|
||||
return rhs != lhs; // Operation is commutative
|
||||
}
|
||||
|
||||
inline bool operator < (detail::stl_type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT {
|
||||
return rhs > lhs;
|
||||
}
|
||||
|
||||
inline bool operator > (detail::stl_type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT {
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
inline bool operator <= (detail::stl_type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT {
|
||||
return rhs >= lhs;
|
||||
}
|
||||
|
||||
inline bool operator >= (detail::stl_type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT {
|
||||
return rhs <= lhs;
|
||||
}
|
||||
|
||||
#else // BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
|
||||
inline bool operator == (std::type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT;
|
||||
inline bool operator != (std::type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT;
|
||||
inline bool operator < (std::type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT;
|
||||
inline bool operator > (std::type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT;
|
||||
inline bool operator <= (std::type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT;
|
||||
inline bool operator >= (std::type_info const& lhs, type_index const& rhs) BOOST_NOEXCEPT;
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
|
||||
/* *************** type_index free functions ******************* */
|
||||
|
||||
#ifndef BOOST_NO_IOSTREAM
|
||||
#ifdef BOOST_NO_TEMPLATED_IOSTREAMS
|
||||
|
||||
/// Ostream operator that will output demangled name.
|
||||
inline std::ostream& operator<<(std::ostream& ostr, type_index const& ind) {
|
||||
ostr << ind.name_demangled();
|
||||
return ostr;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/// Ostream operator that will output demangled name.
|
||||
template <class CharT, class TriatT>
|
||||
inline std::basic_ostream<CharT, TriatT>& operator<<(std::basic_ostream<CharT, TriatT>& ostr, type_index const& ind) {
|
||||
ostr << ind.name_demangled();
|
||||
return ostr;
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_TEMPLATED_IOSTREAMS
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
|
||||
/// hash_value function overload for type_index.
|
||||
inline std::size_t hash_value(type_index const& v) BOOST_NOEXCEPT {
|
||||
return v.hash_code();
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#else // (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
|
||||
#include <boost/type_index/template_index.hpp>
|
||||
namespace boost {
|
||||
|
||||
typedef template_index type_index;
|
||||
|
||||
}
|
||||
|
||||
#endif // (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_TYPE_INDEX_HPP
|
||||
|
@ -1,23 +0,0 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_TEST_MODULE template_index_test_module
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
namespace my_namespace1 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
|
||||
namespace my_namespace2 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
#include "template_index_tests.ipp"
|
||||
|
@ -1,8 +0,0 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_TEST_MODULE testing_both_test_module
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
namespace my_namespace1 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
|
||||
namespace my_namespace2 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
#include "type_index_tests.ipp"
|
||||
#include "template_index_tests.ipp"
|
||||
|
@ -1,27 +0,0 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_TEST_MODULE testing_both_test_module
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#error "This test must be run with disabled RTTI"
|
||||
#endif
|
||||
|
||||
namespace my_namespace1 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
|
||||
namespace my_namespace2 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
#include "type_index_tests.ipp"
|
||||
#include "template_index_tests.ipp"
|
||||
|
@ -1,26 +0,0 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_TEST_MODULE testing_both_test_module
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/type_index/type_index_minimal.hpp>
|
||||
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#error "This test must be run with disabled RTTI"
|
||||
#endif
|
||||
|
||||
namespace my_namespace1 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
|
||||
namespace my_namespace2 {
|
||||
class my_class{};
|
||||
}
|
||||
|
||||
#include "type_index_tests.ipp"
|
||||
|
@ -1,211 +0,0 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(names_matches_type_id)
|
||||
{
|
||||
using namespace boost;
|
||||
BOOST_CHECK_EQUAL(type_id<int>().name_demangled(), "int");
|
||||
BOOST_CHECK_EQUAL(type_id<double>().name_demangled(), "double");
|
||||
|
||||
BOOST_CHECK_EQUAL(type_id<int>().name(), type_id<int>().name());
|
||||
BOOST_CHECK_NE(type_id<int>().name(), type_id<double>().name());
|
||||
BOOST_CHECK_NE(type_id<double>().name(), type_id<int>().name());
|
||||
BOOST_CHECK_EQUAL(type_id<double>().name(), type_id<double>().name());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(comparators_type_id)
|
||||
{
|
||||
using namespace boost;
|
||||
type_index t_int = type_id<int>();
|
||||
type_index t_double = type_id<double>();
|
||||
|
||||
BOOST_CHECK_EQUAL(t_int, t_int);
|
||||
BOOST_CHECK_LE(t_int, t_int);
|
||||
BOOST_CHECK_GE(t_int, t_int);
|
||||
BOOST_CHECK_NE(t_int, t_double);
|
||||
|
||||
BOOST_CHECK_LE(t_double, t_double);
|
||||
BOOST_CHECK_GE(t_double, t_double);
|
||||
BOOST_CHECK_NE(t_double, t_int);
|
||||
|
||||
BOOST_CHECK(t_double < t_int || t_int < t_double);
|
||||
BOOST_CHECK(t_double > t_int || t_int > t_double);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(hash_code_type_id)
|
||||
{
|
||||
using namespace boost;
|
||||
std::size_t t_int1 = type_id<int>().hash_code();
|
||||
std::size_t t_double1 = type_id<double>().hash_code();
|
||||
|
||||
std::size_t t_int2 = type_id<int>().hash_code();
|
||||
std::size_t t_double2 = type_id<double>().hash_code();
|
||||
|
||||
BOOST_CHECK_EQUAL(t_int1, t_int2);
|
||||
BOOST_CHECK_NE(t_int1, t_double2);
|
||||
BOOST_CHECK_LE(t_double1, t_double2);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RTTI
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_NO_RTTI
|
||||
|
||||
template <class T1, class T2>
|
||||
static void test_with_modofiers_type_id() {
|
||||
using namespace boost;
|
||||
|
||||
type_index t1 = type_id_with_cvr<T1>();
|
||||
type_index t2 = type_id_with_cvr<T2>();
|
||||
|
||||
BOOST_CHECK_NE(t2, t1);
|
||||
BOOST_CHECK(t1 < t2 || t2 < t1);
|
||||
BOOST_CHECK(t1 > t2 || t2 > t1);
|
||||
|
||||
BOOST_CHECK_EQUAL(t1, type_id_with_cvr<T1>());
|
||||
BOOST_CHECK_EQUAL(t2, type_id_with_cvr<T2>());
|
||||
|
||||
BOOST_CHECK_EQUAL(t1.hash_code(), type_id_with_cvr<T1>().hash_code());
|
||||
BOOST_CHECK_EQUAL(t2.hash_code(), type_id_with_cvr<T2>().hash_code());
|
||||
|
||||
BOOST_CHECK_NE(t1.hash_code(), type_id_with_cvr<T2>().hash_code());
|
||||
BOOST_CHECK_NE(t2.hash_code(), type_id_with_cvr<T1>().hash_code());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(type_id_storing_modifiers)
|
||||
{
|
||||
test_with_modofiers_type_id<int, const int>();
|
||||
test_with_modofiers_type_id<int, const int&>();
|
||||
test_with_modofiers_type_id<int, int&>();
|
||||
test_with_modofiers_type_id<int, volatile int>();
|
||||
test_with_modofiers_type_id<int, volatile int&>();
|
||||
test_with_modofiers_type_id<int, const volatile int>();
|
||||
test_with_modofiers_type_id<int, const volatile int&>();
|
||||
|
||||
test_with_modofiers_type_id<const int, int>();
|
||||
test_with_modofiers_type_id<const int, const int&>();
|
||||
test_with_modofiers_type_id<const int, int&>();
|
||||
test_with_modofiers_type_id<const int, volatile int>();
|
||||
test_with_modofiers_type_id<const int, volatile int&>();
|
||||
test_with_modofiers_type_id<const int, const volatile int>();
|
||||
test_with_modofiers_type_id<const int, const volatile int&>();
|
||||
|
||||
test_with_modofiers_type_id<const int&, int>();
|
||||
test_with_modofiers_type_id<const int&, const int>();
|
||||
test_with_modofiers_type_id<const int&, int&>();
|
||||
test_with_modofiers_type_id<const int&, volatile int>();
|
||||
test_with_modofiers_type_id<const int&, volatile int&>();
|
||||
test_with_modofiers_type_id<const int&, const volatile int>();
|
||||
test_with_modofiers_type_id<const int&, const volatile int&>();
|
||||
|
||||
test_with_modofiers_type_id<int&, const int>();
|
||||
test_with_modofiers_type_id<int&, const int&>();
|
||||
test_with_modofiers_type_id<int&, int>();
|
||||
test_with_modofiers_type_id<int&, volatile int>();
|
||||
test_with_modofiers_type_id<int&, volatile int&>();
|
||||
test_with_modofiers_type_id<int&, const volatile int>();
|
||||
test_with_modofiers_type_id<int&, const volatile int&>();
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
test_with_modofiers_type_id<int&&, const int>();
|
||||
test_with_modofiers_type_id<int&&, const int&>();
|
||||
test_with_modofiers_type_id<int&&, const int&&>();
|
||||
test_with_modofiers_type_id<int&&, int>();
|
||||
test_with_modofiers_type_id<int&&, volatile int>();
|
||||
test_with_modofiers_type_id<int&&, volatile int&>();
|
||||
test_with_modofiers_type_id<int&&, volatile int&&>();
|
||||
test_with_modofiers_type_id<int&&, const volatile int>();
|
||||
test_with_modofiers_type_id<int&&, const volatile int&>();
|
||||
test_with_modofiers_type_id<int&&, const volatile int&&>();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void test_storing_nonstoring_modifiers() {
|
||||
using namespace boost;
|
||||
|
||||
type_index t1 = type_id_with_cvr<T>();
|
||||
type_index t2 = type_id<T>();
|
||||
|
||||
BOOST_CHECK_EQUAL(t2, t1);
|
||||
BOOST_CHECK_EQUAL(t1, t2);
|
||||
BOOST_CHECK(t1 <= t2);
|
||||
BOOST_CHECK(t1 >= t2);
|
||||
BOOST_CHECK(t2 <= t1);
|
||||
BOOST_CHECK(t2 >= t1);
|
||||
|
||||
BOOST_CHECK_EQUAL(t2.name_demangled(), t1.name_demangled());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(type_id_storing_modifiers_vs_nonstoring)
|
||||
{
|
||||
test_storing_nonstoring_modifiers<int>();
|
||||
test_storing_nonstoring_modifiers<my_namespace1::my_class>();
|
||||
test_storing_nonstoring_modifiers<my_namespace2::my_class>();
|
||||
|
||||
boost::type_index t1 = boost::type_id_with_cvr<const int>();
|
||||
boost::type_index t2 = boost::type_id<int>();
|
||||
BOOST_CHECK_NE(t2, t1);
|
||||
BOOST_CHECK(t1.name_demangled() == "const int" || t1.name_demangled() == "int const");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(type_index_stream_operator_via_lexical_cast_testing)
|
||||
{
|
||||
using namespace boost;
|
||||
std::string s_int1 = lexical_cast<std::string>(type_id<int>());
|
||||
BOOST_CHECK_EQUAL(s_int1, "int");
|
||||
|
||||
std::string s_double1 = lexical_cast<std::string>(type_id<double>());
|
||||
BOOST_CHECK_EQUAL(s_double1, "double");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(type_index_stripping_cvr_test)
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
BOOST_CHECK_EQUAL(type_id<int>(), type_id<const int>());
|
||||
BOOST_CHECK_EQUAL(type_id<int>(), type_id<const volatile int>());
|
||||
BOOST_CHECK_EQUAL(type_id<int>(), type_id<const volatile int&>());
|
||||
|
||||
BOOST_CHECK_EQUAL(type_id<int>(), type_id<int&>());
|
||||
BOOST_CHECK_EQUAL(type_id<int>(), type_id<volatile int>());
|
||||
BOOST_CHECK_EQUAL(type_id<int>(), type_id<volatile int&>());
|
||||
|
||||
|
||||
BOOST_CHECK_EQUAL(type_id<double>(), type_id<const double>());
|
||||
BOOST_CHECK_EQUAL(type_id<double>(), type_id<const volatile double>());
|
||||
BOOST_CHECK_EQUAL(type_id<double>(), type_id<const volatile double&>());
|
||||
|
||||
BOOST_CHECK_EQUAL(type_id<double>(), type_id<double&>());
|
||||
BOOST_CHECK_EQUAL(type_id<double>(), type_id<volatile double>());
|
||||
BOOST_CHECK_EQUAL(type_id<double>(), type_id<volatile double&>());
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(type_index_user_defined_class_test)
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
BOOST_CHECK_EQUAL(type_id<my_namespace1::my_class>(), type_id<my_namespace1::my_class>());
|
||||
BOOST_CHECK_EQUAL(type_id<my_namespace2::my_class>(), type_id<my_namespace2::my_class>());
|
||||
|
||||
|
||||
BOOST_CHECK_NE(type_id<my_namespace1::my_class>(), type_id<my_namespace2::my_class>());
|
||||
BOOST_CHECK_NE(
|
||||
type_id<my_namespace1::my_class>().name_demangled().find("my_namespace1::my_class"),
|
||||
std::string::npos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user