mirror of
https://github.com/boostorg/core.git
synced 2025-08-11 18:54:59 +02:00
Update documentation.
This commit is contained in:
@@ -34,9 +34,11 @@ criteria for inclusion is that the utility component be:
|
|||||||
|
|
||||||
[include:core addressof.qbk]
|
[include:core addressof.qbk]
|
||||||
[include:core checked_delete.qbk]
|
[include:core checked_delete.qbk]
|
||||||
|
[include:core demangle.qbk]
|
||||||
[include:core enable_if.qbk]
|
[include:core enable_if.qbk]
|
||||||
[include:core explicit_operator_bool.qbk]
|
[include:core explicit_operator_bool.qbk]
|
||||||
[include:core ignore_unused.qbk]
|
[include:core ignore_unused.qbk]
|
||||||
|
[include:core is_same.qbk]
|
||||||
[include:core lightweight_test.qbk]
|
[include:core lightweight_test.qbk]
|
||||||
[include:core no_exceptions_support.qbk]
|
[include:core no_exceptions_support.qbk]
|
||||||
[include:core noncopyable.qbk]
|
[include:core noncopyable.qbk]
|
||||||
@@ -44,3 +46,4 @@ criteria for inclusion is that the utility component be:
|
|||||||
[include:core ref.qbk]
|
[include:core ref.qbk]
|
||||||
[include:core scoped_enum.qbk]
|
[include:core scoped_enum.qbk]
|
||||||
[include:core swap.qbk]
|
[include:core swap.qbk]
|
||||||
|
[include:core typeinfo.qbk]
|
||||||
|
74
doc/demangle.qbk
Normal file
74
doc/demangle.qbk
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
[/
|
||||||
|
Copyright 2014 Peter Dimov
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
|
||||||
|
See accompanying file LICENSE_1_0.txt
|
||||||
|
or copy at http://boost.org/LICENSE_1_0.txt
|
||||||
|
]
|
||||||
|
|
||||||
|
[section:demangle demangle]
|
||||||
|
|
||||||
|
[section Authors]
|
||||||
|
|
||||||
|
* Peter Dimov
|
||||||
|
* Andrey Semashev
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Header <boost/core/demangle.hpp>]
|
||||||
|
|
||||||
|
The header `<boost/core/demangle.hpp>` defines the function
|
||||||
|
`boost::core::demangle`. It takes a mangled string such as
|
||||||
|
those returned by `typeid(T).name()` on certain implementations
|
||||||
|
such as `g++`, and returns its demangled, human-readable, form.
|
||||||
|
|
||||||
|
[section Synopsis]
|
||||||
|
|
||||||
|
``
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace core
|
||||||
|
{
|
||||||
|
std::string demangle( char const * name );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
``
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Example]
|
||||||
|
|
||||||
|
``
|
||||||
|
#include <boost/core/demangle.hpp>
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
template<class T> struct X
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char const * name = typeid( X<int> ).name();
|
||||||
|
|
||||||
|
std::cout << name << std::endl; // prints 1XIiE
|
||||||
|
std::cout << boost::core::demangle( name ) << std::endl; // prints X<int>
|
||||||
|
}
|
||||||
|
``
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Acknowledgments]
|
||||||
|
|
||||||
|
The implementation of `core::demangle` was taken from
|
||||||
|
`boost/exception/detail/type_info.hpp`, which in turn was adapted
|
||||||
|
from `boost/units/detail/utility.hpp`.
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
69
doc/is_same.qbk
Normal file
69
doc/is_same.qbk
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
[/
|
||||||
|
Copyright 2014 Peter Dimov
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
|
||||||
|
See accompanying file LICENSE_1_0.txt
|
||||||
|
or copy at http://boost.org/LICENSE_1_0.txt
|
||||||
|
]
|
||||||
|
|
||||||
|
[section:is_same is_same]
|
||||||
|
|
||||||
|
[section Authors]
|
||||||
|
|
||||||
|
* Peter Dimov
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Header <boost/core/is_same.hpp>]
|
||||||
|
|
||||||
|
The header `<boost/core/is_same.hpp>` defines the class template
|
||||||
|
`boost::core::is_same<T1,T2>`. It defines a nested integral constant
|
||||||
|
`value` which is `true` when `T1` and `T2` are the same type, and
|
||||||
|
`false` when they are not.
|
||||||
|
|
||||||
|
In tandem with `BOOST_TEST_TRAIT_TRUE` and `BOOST_TEST_TRAIT_FALSE`,
|
||||||
|
`is_same` is useful for writing tests for traits classes that have
|
||||||
|
to define specific nested types.
|
||||||
|
|
||||||
|
[section Synopsis]
|
||||||
|
|
||||||
|
``
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace core
|
||||||
|
{
|
||||||
|
template<class T1, class T2> struct is_same;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
``
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Example]
|
||||||
|
|
||||||
|
``
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <boost/core/is_same.hpp>
|
||||||
|
|
||||||
|
template<class T> struct X
|
||||||
|
{
|
||||||
|
typedef T& type;
|
||||||
|
};
|
||||||
|
|
||||||
|
using boost::core::is_same;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST_TRAIT_TRUE(( is_same<X<int>::type, int&> ));
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
``
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
@@ -119,7 +119,10 @@ Return the error count from `main`.
|
|||||||
``
|
``
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
int sqr( int x ); // should return x * x
|
int sqr( int x )
|
||||||
|
{
|
||||||
|
return x * x;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -181,7 +184,7 @@ message containing `Trait`. Note the double set of parentheses.
|
|||||||
template<class T, class U> struct X
|
template<class T, class U> struct X
|
||||||
{
|
{
|
||||||
typedef T type;
|
typedef T type;
|
||||||
}
|
};
|
||||||
|
|
||||||
using boost::core::is_same;
|
using boost::core::is_same;
|
||||||
|
|
||||||
|
79
doc/typeinfo.qbk
Normal file
79
doc/typeinfo.qbk
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
[/
|
||||||
|
Copyright 2014 Peter Dimov
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
|
||||||
|
See accompanying file LICENSE_1_0.txt
|
||||||
|
or copy at http://boost.org/LICENSE_1_0.txt
|
||||||
|
]
|
||||||
|
|
||||||
|
[section:typeinfo typeinfo]
|
||||||
|
|
||||||
|
[section Authors]
|
||||||
|
|
||||||
|
* Peter Dimov
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Header <boost/core/typeinfo.hpp>]
|
||||||
|
|
||||||
|
The header `<boost/core/typeinfo.hpp>` defines a class
|
||||||
|
`boost::core::typeinfo`, which is an alias for `std::type_info`
|
||||||
|
when RTTI is enabled, and is a reasonable substitute when RTTI
|
||||||
|
is not supported.
|
||||||
|
|
||||||
|
The macro `BOOST_CORE_TYPEID`, when applied to a type `T`, is the
|
||||||
|
equivalent of `typeid(T)` and produces a reference to a const
|
||||||
|
`typeinfo` object.
|
||||||
|
|
||||||
|
The function `boost::core::demangled_name` takes a
|
||||||
|
`boost::core::typeinfo const & ti` and either returns `ti.name()`,
|
||||||
|
when that string doesn't need to be demangled, or
|
||||||
|
`boost::core::demangle(ti.name())`, when it does. The return type
|
||||||
|
of `boost::core::demangled_name` is `char const*` in the first case
|
||||||
|
and `std::string` in the second.
|
||||||
|
|
||||||
|
[section Synopsis]
|
||||||
|
|
||||||
|
``
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace core
|
||||||
|
{
|
||||||
|
class typeinfo;
|
||||||
|
/* char const* or std::string */ demangled_name( typeinfo const & ti );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BOOST_CORE_TYPEID(T) /*unspecified*/
|
||||||
|
``
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Example]
|
||||||
|
|
||||||
|
``
|
||||||
|
#include <boost/core/typeinfo.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
template<class T1, class T2> struct X
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef X<void const*, void(*)(float)> T;
|
||||||
|
|
||||||
|
boost::core::typeinfo const & ti = BOOST_CORE_TYPEID(T);
|
||||||
|
|
||||||
|
std::cout << boost::core::demangled_name( ti ) << std::endl;
|
||||||
|
}
|
||||||
|
``
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
Reference in New Issue
Block a user