In the middle of changes

This commit is contained in:
Antony Polukhin
2013-10-26 21:00:25 +04:00
parent 5d71c723cc
commit 2a45139fd3
2 changed files with 77 additions and 27 deletions

View File

@@ -6,20 +6,20 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_TYPE_INDEX_TEMPLATE_INFO_IMPL_HPP
#define BOOST_TYPE_INDEX_TEMPLATE_INFO_IMPL_HPP
#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_impl.hpp
/// \file template_info.hpp
/// \brief Contains implementation of boost::template_info class.
///
/// boost::template_info class is used instead of boost::type_info in situations when RTTI is disabled.
///
/// Consider including <boost/type_index/type_info.hpp> or <boost/type_index.hpp> instead of this file.
/// boost::template_info class is used instead of boost::type_index class in situations when RTTI is disabled.
/// It combines functionality of std::type_info and std::type_index.
#include <cstring>
#include <string>
@@ -30,6 +30,15 @@
#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 {
@@ -51,12 +60,12 @@ namespace detail {
#elif defined(BOOST_TYPE_INDEX_FUNCTION_SIGNATURE)
template <class T>
inline void lazy_function_signature_assert() BOOST_NOEXCEPT {}
inline void lazy_function_signature_assert(){}
#elif defined(__FUNCSIG__)
template <class T>
inline void lazy_function_signature_assert() BOOST_NOEXCEPT {}
inline void lazy_function_signature_assert(){}
#define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE __FUNCSIG__
#elif defined(__PRETTY_FUNCTION__) \
@@ -67,13 +76,13 @@ inline void lazy_function_signature_assert() BOOST_NOEXCEPT {}
|| defined(__DMC__)
template <class T>
inline void lazy_function_signature_assert() BOOST_NOEXCEPT {}
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_NOEXCEPT {
inline void lazy_function_signature_assert() {
BOOST_STATIC_ASSERT_MSG(
sizeof(T) && false,
"TypeIndex library could not detect your compiler. "
@@ -140,7 +149,7 @@ inline void lazy_function_signature_assert() BOOST_NOEXCEPT {
/// Copyable type_info that does not require RTTI and could store const,
/// volatile and references if constructed via construct_with_cvr()
class template_info: boost::noncopyable {
class template_info {
private:
const char* name_;
@@ -151,10 +160,15 @@ private:
/// @endcond
public:
/// Factory method for constructing template_index instance for type T.
/// Default constructor.
template_info() BOOST_NOEXCEPT
: name_(detail::ctti<void>::name())
{}
/// Factory method for constructing template_info instance for type T.
/// Strips const, volatile and & modifiers from T
template <class T>
static const template_info& construct() BOOST_NOEXCEPT {
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;
@@ -164,21 +178,21 @@ public:
, "Your EDG-based compiler seems to mistakenly distinguish 'int' from 'signed int', in typeid() expressions.");
#endif
static const template_index ret(detail::ctti<no_cvr_t>::name())
static const template_info ret(detail::ctti<no_cvr_t>::name());
return ret;
}
/// Factory method for constructing template_index instance for type T.
/// Factory method for constructing template_info instance for type T.
/// Does not strip const, volatile and & modifiers from T
template <class T>
static const template_info& construct_with_cvr() BOOST_NOEXCEPT {
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_index ret(detail::ctti<T>::name())
static const template_info ret(detail::ctti<T>::name());
return ret;
}
@@ -199,6 +213,7 @@ public:
return std::string(name_, std::strlen(name_ + detail::ctti_skip_size_at_end));
}
/// @cond
bool operator == (const template_info& rhs) const BOOST_NOEXCEPT {
return !std::strcmp(name_, rhs.name());
}
@@ -206,36 +221,71 @@ public:
bool operator != (const template_info& rhs) const BOOST_NOEXCEPT {
return !!std::strcmp(name_, rhs.name());
}
bool operator < (const template_info& rhs) const BOOST_NOEXCEPT {
return std::strcmp(name_, rhs.name()) < 0;
}
bool operator > (const template_info& rhs) const BOOST_NOEXCEPT {
return std::strcmp(name_, rhs.name()) > 0;
}
bool operator <= (const template_info& rhs) const BOOST_NOEXCEPT {
return std::strcmp(name_, rhs.name()) <= 0;
}
bool operator >= (const template_info& rhs) const BOOST_NOEXCEPT {
return std::strcmp(name_, rhs.name()) >= 0;
}
/// @endcond
/// 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_index instance for type T.
/// 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_index::construct<T>();
return template_info::construct<T>();
}
/// Factory method for constructing template_index instance for type T.
/// Factory 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_index::construct_with_cvr<T>();
return template_info::construct_with_cvr<T>();
}
/* *************** template_info free functions ******************* */
/// hash_value function overload for template_index
#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_INDEX_IMPL_HPP
#endif // BOOST_TYPE_INDEX_TEMPLATE_INFO_HPP

View File

@@ -262,16 +262,16 @@ inline std::size_t hash_value(type_index const& v) BOOST_NOEXCEPT {
namespace boost {
typedef template_index type_index;
typedef template_info type_index;
template <class T>
inline const type_index& type_id() BOOST_NOEXCEPT {
return template_index::construct<T>();
return template_info::construct<T>();
}
template <class T>
inline const type_index& type_id_with_cvr() BOOST_NOEXCEPT {
return template_index::construct_with_cvr<T>();
return template_info::construct_with_cvr<T>();
}
template <class T>