forked from boostorg/type_index
Sources cleanup and some typo fixes
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
[library Boost.TypeIndex
|
||||
[quickbook 1.6]
|
||||
[version 3.0]
|
||||
[copyright 2012-2013 Antony Polukhin]
|
||||
[copyright 2012-2014 Antony Polukhin]
|
||||
[category Language Features Emulation]
|
||||
[license
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
@ -1,51 +0,0 @@
|
||||
// Copyright 2013-2014 Antony Polukhin
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
//[type_index_my_type_index_sources
|
||||
/*`
|
||||
The following example shows how to create an own type_info clas and how
|
||||
to use it all around the project.
|
||||
*/
|
||||
|
||||
#define BOOST_TYPE_INDEX_USER_TYPEINFO \
|
||||
"../../../libs/type_index/examples/my_type_index.hpp"
|
||||
#define BOOST_TYPE_INDEX_USER_TYPEINFO_NAME my_namespace::my_type_info
|
||||
#include <boost/type_index.hpp>
|
||||
#include <cassert>
|
||||
|
||||
class Base {
|
||||
public:
|
||||
virtual my_type_index type_info() const BOOST_NOEXCEPT {
|
||||
return boost::typeind::type_info<Base>();
|
||||
}
|
||||
virtual ~Base(){}
|
||||
};
|
||||
|
||||
class Derived: public Base {
|
||||
public:
|
||||
virtual my_type_index type_info() const BOOST_NOEXCEPT {
|
||||
return boost::typeind::type_id<Derived>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
using boost::typeind;
|
||||
|
||||
int main() {
|
||||
Base base;
|
||||
Derived derived;
|
||||
|
||||
Base& derived_as_base;
|
||||
|
||||
assert(type_id_runtime(derived) == type_id_runtime(derived_as_base));
|
||||
assert(type_id_runtime(base) != type_id_runtime(derived_as_base));
|
||||
assert(type_id_runtime(base) != type_id_runtime(derived));
|
||||
assert(type_id_runtime(derived_as_base).pretty_name() == "Derived");
|
||||
}
|
||||
|
||||
//] [/type_index_registry_example]
|
||||
|
||||
//] [/type_index_my_type_index_sources]
|
@ -1,35 +0,0 @@
|
||||
// Copyright 2013-2014 Antony Polukhin
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
//[type_index_my_type_index
|
||||
/*`
|
||||
The following example shows how to create an own type_info clas and how
|
||||
to use it all around the project.
|
||||
*/
|
||||
|
||||
#ifndef MY_NAMESPACE_MY_TYPE_INDEX_HPP
|
||||
#define MY_NAMESPACE_MY_TYPE_INDEX_HPP
|
||||
|
||||
// We'll use ctti_type_info as a base class for my_type_info
|
||||
#include <boost/type_index/ctti_type_info.hpp>
|
||||
namespace my_namespace {
|
||||
|
||||
struct my_type_index: public ctti_type_info {
|
||||
my_type_index(const ctti_type_info::type_info_t& data) BOOST_NOEXCEPT
|
||||
: ctti_type_info(data)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
static inline my_type_info construct_runtime(const T& value) BOOST_NOEXCEPT {
|
||||
return value.type_info();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace my_namespace
|
||||
|
||||
#endif // MY_NAMESPACE_MY_TYPE_INDEX_HPP
|
||||
//] [/type_index_my_type_index]
|
||||
|
@ -53,10 +53,6 @@ namespace boost { namespace typeind {
|
||||
/// some user defined class.
|
||||
typedef type_index::type_info_t type_info;
|
||||
|
||||
// TODO:
|
||||
// inline bool is_equal(const type_info&, const type_info&) BOOST_NOEXCEPT;
|
||||
// inline bool is_before(const type_info&, const type_info&) BOOST_NOEXCEPT;
|
||||
|
||||
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_USER_TYPEINFO
|
||||
|
@ -145,7 +145,7 @@ protected:
|
||||
/// \param variable Variable which runtime type will be stored in type_index.
|
||||
/// \return type_index with runtime type of variable.
|
||||
template <class T>
|
||||
static Derived type_id_runtime(const T& variablel) BOOST_NOEXCEPT;
|
||||
static Derived type_id_runtime(const T& variable) BOOST_NOEXCEPT;
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user