Modernize the code (#19)

This commit is contained in:
Antony Polukhin
2025-12-23 20:23:47 +03:00
committed by GitHub
parent f2a3bdd29c
commit 97346351f8
13 changed files with 43 additions and 51 deletions

View File

@@ -41,13 +41,6 @@ jobs:
linkflags: "linkflags=--coverage -lasan -lubsan"
gcov_tool: "gcov-10"
launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.6"
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
linkflags: "linkflags=--coverage -lasan -lubsan"
gcov_tool: "gcov-9"
launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.5"
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,2a"

View File

@@ -31,7 +31,7 @@ boostbook standalone
:
type_index
:
<xsl:param>boost.root=http://www.boost.org/doc/libs/1_53_0
<xsl:param>boost.root=http://www.boost.org/doc/libs/1_90_0
# <xsl:param>boost.root=../../../..
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
;

View File

@@ -23,8 +23,8 @@ namespace my_namespace {
class my_class;
struct my_struct;
typedef std::vector<my_class> my_classes;
typedef std::string my_string;
using my_classes = std::vector<my_class>;
using my_string = std::string;
} // namespace my_namespace
@@ -96,21 +96,21 @@ class my_type_index: public boost::typeindex::type_index_facade<my_type_index, d
const detail::my_typeinfo* data_;
public:
typedef detail::my_typeinfo type_info_t;
using type_info_t = detail::my_typeinfo;
inline my_type_index() BOOST_NOEXCEPT
inline my_type_index() noexcept
: data_(&detail::my_typeinfo_construct<void>())
{}
inline my_type_index(const type_info_t& data) BOOST_NOEXCEPT
inline my_type_index(const type_info_t& data) noexcept
: data_(&data)
{}
inline const type_info_t& type_info() const BOOST_NOEXCEPT {
inline const type_info_t& type_info() const noexcept {
return *data_;
}
inline const char* raw_name() const BOOST_NOEXCEPT {
inline const char* raw_name() const noexcept {
return data_->type_;
}
@@ -119,17 +119,17 @@ public:
}
template <class T>
inline static my_type_index type_id() BOOST_NOEXCEPT {
inline static my_type_index type_id() noexcept {
return detail::my_typeinfo_construct<T>();
}
template <class T>
inline static my_type_index type_id_with_cvr() BOOST_NOEXCEPT {
inline static my_type_index type_id_with_cvr() noexcept {
return detail::my_typeinfo_construct<T>();
}
template <class T>
inline static my_type_index type_id_runtime(const T& variable) BOOST_NOEXCEPT;
inline static my_type_index type_id_runtime(const T& variable) noexcept;
};
} // namespace my_namespace
@@ -168,7 +168,7 @@ namespace my_namespace { namespace detail {
*/
namespace my_namespace {
template <class T>
my_type_index my_type_index::type_id_runtime(const T& variable) BOOST_NOEXCEPT {
my_type_index my_type_index::type_id_runtime(const T& variable) noexcept {
// Classes that were marked with `MY_TYPEINDEX_REGISTER_CLASS` will have a
// `type_id_runtime()` method.
return variable.type_id_runtime();
@@ -204,7 +204,7 @@ struct my_struct: public my_class {
*/
#define BOOST_TYPE_INDEX_REGISTER_CLASS MY_TYPEINDEX_REGISTER_CLASS
namespace boost { namespace typeindex {
typedef my_namespace::my_type_index type_index;
using type_index = my_namespace::my_type_index;
}}
//] [/type_index_my_type_index_worldwide_typedefs]

View File

@@ -129,13 +129,13 @@ BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT
/// user defined type_index class.
///
/// \b See boost::typeindex::type_index_facade for a full description of type_index functions.
typedef platform_specific type_index;
using type_index = platform_specific;
#elif defined(BOOST_TYPE_INDEX_USER_TYPEINDEX)
// Nothing to do
#elif (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
typedef boost::typeindex::stl_type_index type_index;
using type_index = boost::typeindex::stl_type_index;
#else
typedef boost::typeindex::ctti_type_index type_index;
using type_index = boost::typeindex::ctti_type_index;
#endif
/// Depending on a compiler flags, optimal implementation of type_info will be used
@@ -145,7 +145,7 @@ BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT
/// some user defined class.
///
/// type_info \b is \b not copyable or default constructible. It is \b not assignable too!
typedef type_index::type_info_t type_info;
using type_info = type_index::type_info_t;
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)

View File

@@ -112,7 +112,7 @@ class ctti_type_index: public type_index_facade<ctti_type_index, detail::ctti_da
{}
public:
typedef detail::ctti_data type_info_t;
using type_info_t = detail::ctti_data;
BOOST_CXX14_CONSTEXPR inline ctti_type_index() noexcept
: data_(boost::detail::ctti<void>::n())
@@ -164,8 +164,8 @@ BOOST_CXX14_CONSTEXPR inline bool ctti_type_index::before(const ctti_type_index&
template <class T>
BOOST_CXX14_CONSTEXPR inline ctti_type_index ctti_type_index::type_id() noexcept {
typedef typename std::remove_reference<T>::type no_ref_t;
typedef typename std::remove_cv<no_ref_t>::type no_cvr_t;
using no_ref_t = typename std::remove_reference<T>::type;
using no_cvr_t = typename std::remove_cv<no_ref_t>::type;
return ctti_type_index(boost::detail::ctti<no_cvr_t>::n());
}

View File

@@ -224,25 +224,25 @@ constexpr ctti_skip skip() noexcept { return detail::make_ctti_skip(0, 0, ""); }
template <unsigned int... Left, unsigned int... Right>
struct make_index_sequence_join<index_seq<Left...>, index_seq<Right...> > {
typedef index_seq<Left..., Right...> type;
using type = index_seq<Left..., Right...>;
};
template <unsigned int C, unsigned int D>
struct make_index_seq_impl {
typedef typename make_index_sequence_join<
using type = typename make_index_sequence_join<
typename make_index_seq_impl<C, D / 2>::type,
typename make_index_seq_impl<C + D / 2, (D + 1) / 2>::type
>::type type;
>::type;
};
template <unsigned int C>
struct make_index_seq_impl<C, 0> {
typedef index_seq<> type;
using type = index_seq<>;
};
template <unsigned int C>
struct make_index_seq_impl<C, 1> {
typedef index_seq<C> type;
using type = index_seq<C>;
};
template <char... C>
@@ -315,10 +315,10 @@ struct ctti {
>();
static_assert(!boost::typeindex::detail::skip().until_runtime_length, "Skipping for GCC in C++14 mode is unsupported");
typedef typename boost::typeindex::detail::make_index_seq_impl<
using idx_seq = typename boost::typeindex::detail::make_index_seq_impl<
boost::typeindex::detail::skip().size_at_begin,
size - sizeof("const *") + 1 - boost::typeindex::detail::skip().size_at_begin
>::type idx_seq;
>::type;
return impl(idx_seq());
}
#else

View File

@@ -35,7 +35,7 @@ BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT
/// an address suitably offset from u. If no such conversion exists, returns nullptr.
template<typename T, typename U>
T runtime_cast(U* u) noexcept {
typedef typename std::remove_pointer<T>::type impl_type;
using impl_type = typename std::remove_pointer<T>::type;
return detail::runtime_cast_impl<impl_type>(u, std::is_base_of<T, U>());
}
@@ -46,7 +46,7 @@ T runtime_cast(U* u) noexcept {
/// an address suitably offset from u. If no such conversion exists, returns nullptr.
template<typename T, typename U>
T runtime_cast(U const* u) noexcept {
typedef typename std::remove_pointer<T>::type impl_type;
using impl_type = typename std::remove_pointer<T>::type;
return detail::runtime_cast_impl<impl_type>(u, std::is_base_of<T, U>());
}

View File

@@ -46,7 +46,7 @@ struct BOOST_SYMBOL_VISIBLE bad_runtime_cast : std::exception
/// suitably offset from u. If no such conversion exists, throws boost::typeindex::bad_runtime_cast.
template<typename T, typename U>
typename std::add_lvalue_reference<T>::type runtime_cast(U& u) {
typedef typename std::remove_reference<T>::type impl_type;
using impl_type = typename std::remove_reference<T>::type;
impl_type* value = detail::runtime_cast_impl<impl_type>(
std::addressof(u), std::is_base_of<T, U>());
if(!value)
@@ -61,7 +61,7 @@ typename std::add_lvalue_reference<T>::type runtime_cast(U& u) {
/// suitably offset from u. If no such conversion exists, throws boost::typeindex::bad_runtime_cast.
template<typename T, typename U>
typename std::add_lvalue_reference<const T>::type runtime_cast(U const& u) {
typedef typename std::remove_reference<T>::type impl_type;
using impl_type = typename std::remove_reference<T>::type;
impl_type* value = detail::runtime_cast_impl<impl_type>(
std::addressof(u), std::is_base_of<T, U>());
if(!value)

View File

@@ -117,9 +117,9 @@ class stl_type_index
{
public:
#ifdef BOOST_NO_STD_TYPEINFO
typedef type_info type_info_t;
using type_info_t = type_info;
#else
typedef std::type_info type_info_t;
using type_info_t = std::type_info;
#endif
private:
@@ -175,7 +175,7 @@ inline const char* stl_type_index::name() const noexcept {
inline std::string stl_type_index::pretty_name() const {
static const char cvr_saver_name[] = "boost::typeindex::detail::cvr_saver";
static BOOST_CONSTEXPR_OR_CONST std::string::size_type cvr_saver_name_len = sizeof(cvr_saver_name) - 1;
constexpr std::string::size_type cvr_saver_name_len = sizeof(cvr_saver_name) - 1;
// In case of MSVC demangle() is a no-op, and name() already returns demangled name.
// In case of GCC and Clang (on non-Windows systems) name() returns mangled name and demangle() undecorates it.
@@ -270,8 +270,8 @@ inline bool stl_type_index::before(const stl_type_index& rhs) const noexcept {
template <class T>
inline stl_type_index stl_type_index::type_id() noexcept {
typedef typename std::remove_reference<T>::type no_ref_t;
typedef typename std::remove_cv<no_ref_t>::type no_cvr_t;
using no_ref_t = typename std::remove_reference<T>::type;
using no_cvr_t = typename std::remove_cv<no_ref_t>::type;
return typeid(no_cvr_t);
}
@@ -281,11 +281,11 @@ namespace detail {
template <class T>
inline stl_type_index stl_type_index::type_id_with_cvr() noexcept {
typedef typename std::conditional<
using type = typename std::conditional<
std::is_reference<T>::value || std::is_const<T>::value || std::is_volatile<T>::value,
detail::cvr_saver<T>,
T
>::type type;
>::type;
return typeid(type);
}

View File

@@ -42,7 +42,7 @@ BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT
/// class stl_type_index: public type_index_facade<stl_type_index, std::type_info>
/// {
/// public:
/// typedef std::type_info type_info_t;
/// using type_info_t = std::type_info;
/// private:
/// const type_info_t* data_;
///
@@ -70,7 +70,7 @@ private:
}
/// @endcond
public:
typedef TypeInfo type_info_t;
using type_info_t = TypeInfo;
/// \b Override: This function \b may be redefined in Derived class. Overrides \b must not throw.
/// \return Name of a type. By default returns Derived::raw_name().

View File

@@ -14,7 +14,6 @@ foreach(dep IN ITEMS
describe
mp11
smart_ptr
static_assert
throw_exception
unordered
predef)

View File

@@ -31,8 +31,8 @@ struct my_template {};
template<typename T>
void compare()
{
typedef boost::typeindex::ctti_type_index ctti;
typedef boost::typeindex::stl_type_index stl;
using ctti = boost::typeindex::ctti_type_index;
using stl = boost::typeindex::stl_type_index;
BOOST_TEST_EQ(
ctti::type_id<T>().pretty_name(),
stl::type_id<T>().pretty_name()

View File

@@ -36,7 +36,7 @@ int main()
<< ctti_type_index::type_id<user_defined_namespace::user_defined_class>() << '\n';
std::cout << "empty:"
std::cout << "empty: "
<< ctti_type_index::type_id<empty>() << '\n';
return 0;