-
Notifications
You must be signed in to change notification settings - Fork 57
Implement initial version of C++20 module boost.type_index
#15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
979fc6d
9277105
8eee897
94b2bd6
470a909
6d11c7a
a99594c
217d7ef
de1732c
c8abcb2
90f9dc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| /// By inclusion of this file most optimal type index classes will be included and used | ||
| /// as a boost::typeindex::type_index and boost::typeindex::type_info. | ||
|
|
||
| #include <boost/config.hpp> | ||
| #include <boost/type_index/detail/config.hpp> | ||
|
|
||
| #ifdef BOOST_HAS_PRAGMA_ONCE | ||
| # pragma once | ||
|
|
@@ -49,8 +49,12 @@ | |
| #define BOOST_TYPE_INDEX_REGISTER_CLASS | ||
| #endif | ||
|
|
||
| #if !defined(BOOST_USE_MODULES) || defined(BOOST_TYPE_INDEX_INTERFACE_UNIT) | ||
|
|
||
| namespace boost { namespace typeindex { | ||
|
|
||
| BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT | ||
|
|
||
| #if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED) | ||
|
|
||
| /// \def BOOST_TYPE_INDEX_FUNCTION_SIGNATURE | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are macros like |
||
|
|
@@ -257,9 +261,11 @@ inline type_index type_id_runtime(const T& runtime_val) noexcept { | |
| return type_index::type_id_runtime(runtime_val); | ||
| } | ||
|
|
||
| }} // namespace boost::typeindex | ||
| BOOST_TYPE_INDEX_END_MODULE_EXPORT | ||
|
|
||
| }} // namespace boost::typeindex | ||
|
|
||
| #endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_TYPE_INDEX_INTERFACE_UNIT) | ||
|
|
||
| #endif // BOOST_TYPE_INDEX_HPP | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,12 +18,19 @@ | |
| /// It is used in situations when typeid() method is not available or | ||
| /// BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY macro is defined. | ||
|
|
||
| #include <boost/type_index/detail/config.hpp> | ||
|
|
||
| #if !defined(BOOST_USE_MODULES) || defined(BOOST_TYPE_INDEX_INTERFACE_UNIT) | ||
|
|
||
| #include <boost/type_index/type_index_facade.hpp> | ||
| #include <boost/type_index/detail/compile_time_type_info.hpp> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file has STL headers that are not ifdef'ed out. |
||
|
|
||
| #if !defined(BOOST_TYPE_INDEX_INTERFACE_UNIT) | ||
| #include <cstring> | ||
| #include <type_traits> | ||
|
|
||
| #include <boost/container_hash/hash.hpp> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to ifdef-out other Boost headers, too. |
||
| #endif | ||
|
|
||
| #ifdef BOOST_HAS_PRAGMA_ONCE | ||
| # pragma once | ||
|
|
@@ -64,6 +71,8 @@ class ctti_data { | |
|
|
||
| } // namespace detail | ||
|
|
||
| BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT | ||
|
|
||
| /// Helper method for getting detail::ctti_data of a template parameter T. | ||
| template <class T> | ||
| inline const detail::ctti_data& ctti_construct() noexcept { | ||
|
|
@@ -132,6 +141,8 @@ class ctti_type_index: public type_index_facade<ctti_type_index, detail::ctti_da | |
| inline static ctti_type_index type_id_runtime(const T& variable) noexcept; | ||
| }; | ||
|
|
||
| BOOST_TYPE_INDEX_END_MODULE_EXPORT | ||
|
|
||
|
|
||
| inline const ctti_type_index::type_info_t& ctti_type_index::type_info() const noexcept { | ||
| return *reinterpret_cast<const detail::ctti_data*>(data_); | ||
|
|
@@ -197,8 +208,9 @@ inline std::size_t ctti_type_index::hash_code() const noexcept { | |
| return boost::hash_range(raw_name(), raw_name() + get_raw_name_length()); | ||
| } | ||
|
|
||
|
|
||
| }} // namespace boost::typeindex | ||
|
|
||
| #endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_TYPE_INDEX_INTERFACE_UNIT) | ||
|
|
||
| #endif // BOOST_TYPE_INDEX_CTTI_TYPE_INDEX_HPP | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // | ||
| // Copyright 2013-2025 Antony Polukhin. | ||
| // | ||
| // | ||
| // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| // | ||
|
|
||
| #ifndef BOOST_TYPE_INDEX_DETAIL_CONFIG_HPP | ||
| #define BOOST_TYPE_INDEX_DETAIL_CONFIG_HPP | ||
|
|
||
| #if !defined(BOOST_TYPE_INDEX_INTERFACE_UNIT) | ||
| #include <boost/config.hpp> | ||
| #ifdef BOOST_HAS_PRAGMA_ONCE | ||
| # pragma once | ||
| #endif | ||
| #endif | ||
|
|
||
| #ifdef BOOST_TYPE_INDEX_INTERFACE_UNIT | ||
| # define BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT export { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
| # define BOOST_TYPE_INDEX_END_MODULE_EXPORT } | ||
| #else | ||
| # define BOOST_TYPE_INDEX_BEGIN_MODULE_EXPORT | ||
| # define BOOST_TYPE_INDEX_END_MODULE_EXPORT | ||
| #endif | ||
|
|
||
| #if defined(BOOST_USE_MODULES) && !defined(BOOST_TYPE_INDEX_INTERFACE_UNIT) | ||
| import boost.type_index; | ||
| #endif | ||
|
|
||
| #endif // BOOST_TYPE_INDEX_DETAIL_CONFIG_HPP | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I missing something or is there no
${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt? I'd advise to remove this check if you know for sure that the file should be present. AFAIK this is generated by Peter's CMake generator so it's compatible with libraries that don't run their tests via CMake.