diff --git a/doc/type_index.qbk b/doc/type_index.qbk index d029d68..ef3be83 100644 --- a/doc/type_index.qbk +++ b/doc/type_index.qbk @@ -37,9 +37,6 @@ is a drop-in replacement for `std::type_index`. Unlike Standard Library versions `type_index` provides the full set of comparison operators, hashing functions and ostream operators, so it can be used with any container class. -Through all the examples, we'll assume that the following namespace alias is in effect: -``namespace bti = boost::typeind;`` - [section How to use] To start using Boost.TypeIndex: @@ -56,7 +53,7 @@ To start using Boost.TypeIndex: [[`` std::type_index ``][`` - bti::type_index + boost::typeind::type_index ``]] [[`` @@ -65,18 +62,18 @@ To start using Boost.TypeIndex: typeid(T).name() // not human readable typeid(variable) ``][`` - bti::type_id() - bti::type_id_with_cvr() - bti::type_id().pretty_name() // human readable - bti::type_id_runtime(variable) + boost::typeind::type_id() + boost::typeind::type_id_with_cvr() + boost::typeind::type_id().pretty_name() // human readable + boost::typeind::type_id_runtime(variable) ``]] [[`` const std::type_info& v1 = typeid(int); // when reference to `std::type_info` is required const std::type_info* v2 = &typeid(int); // other cases ``][`` - const bti::type_info& v1 = bti::type_id().type_info(); - bti::type_index v2 = bti::type_id(); + const boost::typeind::type_info& v1 = boost::typeind::type_id().type_info(); + boost::typeind::type_index v2 = boost::typeind::type_id(); ``]] ] @@ -98,10 +95,10 @@ Here is how TypeIndex could be used in `boost/any.hpp`: return typeid(ValueType); } ``] [`` - virtual const bti::type_info & type() const BOOST_NOEXCEPT + virtual const boost::typeind::type_info & type() const BOOST_NOEXCEPT { // now works even with RTTI disabled - return bti::type_id().type_info(); + return boost::typeind::type_id().type_info(); } ``]] ] @@ -141,14 +138,14 @@ public: // visitor interfaces #endif // BOOST_NO_TYPEID ``][`` class reflect - : public static_visitor + : public static_visitor { public: // visitor interfaces template - const bti::type_info& operator()(const T&) const BOOST_NOEXCEPT + const boost::typeind::type_info& operator()(const T&) const BOOST_NOEXCEPT { - return bti::type_id().type_info(); + return boost::typeind::type_id().type_info(); } }; @@ -162,7 +159,7 @@ public: // visitor interfaces } #endif ``] [`` - const bti::type_info& type() const + const boost::typeind::type_info& type() const { detail::variant::reflect visitor; return this->apply_visitor(visitor); diff --git a/examples/demangled_names.cpp b/examples/demangled_names.cpp index d79b5af..bcaecf5 100644 --- a/examples/demangled_names.cpp +++ b/examples/demangled_names.cpp @@ -18,8 +18,8 @@ namespace bti = boost::typeind; template void foo(T) { - std::cout << "\n Short name: " << bti::type_id().raw_name(); - std::cout << "\n Readable name: " << bti::type_id().pretty_name(); + std::cout << "\n Short name: " << boost::typeind::type_id().raw_name(); + std::cout << "\n Readable name: " << boost::typeind::type_id().pretty_name(); } struct user_defined_type{}; diff --git a/examples/exact_types_match.cpp b/examples/exact_types_match.cpp index 94bed1b..fd23f50 100644 --- a/examples/exact_types_match.cpp +++ b/examples/exact_types_match.cpp @@ -18,22 +18,21 @@ #include #include #include -namespace bti = boost::typeind; class type_erased_unary_function { - void* function_ptr_; - bti::type_index exact_param_t_; + void* function_ptr_; + boost::typeind::type_index exact_param_t_; public: template type_erased_unary_function(void(*ptr)(ParamT)) : function_ptr_(reinterpret_cast(ptr)) // ptr - is a pointer to function returning `void` and accepting parameter of type `ParamT` - , exact_param_t_(bti::type_id_with_cvr()) + , exact_param_t_(boost::typeind::type_id_with_cvr()) {} template void call(ParamT v) { - if (exact_param_t_ != bti::type_id_with_cvr()) { + if (exact_param_t_ != boost::typeind::type_id_with_cvr()) { throw std::runtime_error("Incorrect `ParamT`"); } diff --git a/examples/inheritance.cpp b/examples/inheritance.cpp index 35b0afc..caf1dfb 100644 --- a/examples/inheritance.cpp +++ b/examples/inheritance.cpp @@ -14,7 +14,6 @@ #include #include -namespace bti = boost::typeind; struct A { BOOST_TYPE_INDEX_REGISTER_CLASS @@ -24,7 +23,7 @@ struct B: public A { BOOST_TYPE_INDEX_REGISTER_CLASS }; struct C: public B { BOOST_TYPE_INDEX_REGISTER_CLASS }; void print_real_type(const A& a) { - std::cout << bti::type_id_runtime(a).pretty_name() << '\n'; + std::cout << boost::typeind::type_id_runtime(a).pretty_name() << '\n'; } int main() { diff --git a/examples/registry.cpp b/examples/registry.cpp index 44f37c4..457cce9 100644 --- a/examples/registry.cpp +++ b/examples/registry.cpp @@ -14,25 +14,24 @@ #include #include #include -namespace bti = boost::typeind; int main() { - boost::unordered_set types; + boost::unordered_set types; // Storing some `boost::type_info`s - types.insert(bti::type_id()); - types.insert(bti::type_id()); + types.insert(boost::typeind::type_id()); + types.insert(boost::typeind::type_id()); // `types` variable contains two `boost::type_index`es: assert(types.size() == 2); // Const, volatile and reference will be striped from the type: - bool is_inserted = types.insert(bti::type_id()).second; + bool is_inserted = types.insert(boost::typeind::type_id()).second; assert(!is_inserted); - assert(types.erase(bti::type_id()) == 1); + assert(types.erase(boost::typeind::type_id()) == 1); // We have erased the `float` type, only `int` remains - assert(*types.begin() == bti::type_id()); + assert(*types.begin() == boost::typeind::type_id()); } //] [/type_index_registry_example]