-
Notifications
You must be signed in to change notification settings - Fork 55
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 10 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 |
|---|---|---|
|
|
@@ -3,17 +3,36 @@ | |
| # Distributed under the Boost Software License, Version 1.0. | ||
| # https://www.boost.org/LICENSE_1_0.txt | ||
|
|
||
| cmake_minimum_required(VERSION 3.5...3.20) | ||
| cmake_minimum_required(VERSION 3.5...3.31) | ||
|
|
||
| project(boost_type_index VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) | ||
|
|
||
| add_library(boost_type_index INTERFACE) | ||
| add_library(Boost::type_index ALIAS boost_type_index) | ||
| if (BOOST_USE_MODULES) | ||
| add_library(boost_type_index) | ||
| target_sources(boost_type_index PUBLIC | ||
| FILE_SET modules_public TYPE CXX_MODULES FILES | ||
| ${CMAKE_CURRENT_LIST_DIR}/modules/type_index.cppm | ||
| ) | ||
|
|
||
| target_compile_features(boost_type_index PUBLIC cxx_std_20) | ||
| target_compile_definitions(boost_type_index PUBLIC BOOST_USE_MODULES) | ||
| if (CMAKE_CXX_COMPILER_IMPORT_STD) | ||
| target_compile_definitions(boost_type_index PRIVATE BOOST_TYPE_INDEX_USE_STD_MODULE) | ||
| message(STATUS "Using `import std;`") | ||
| else() | ||
| message(STATUS "`import std;` is not awailable") | ||
| endif() | ||
| set(__scope PUBLIC) | ||
| else() | ||
| add_library(boost_type_index INTERFACE) | ||
| set(__scope INTERFACE) | ||
| endif() | ||
|
|
||
|
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. Am I missing something or is there no |
||
| target_include_directories(boost_type_index INTERFACE include) | ||
| target_include_directories(boost_type_index ${__scope} include) | ||
| add_library(Boost::type_index ALIAS boost_type_index) | ||
|
|
||
| target_link_libraries(boost_type_index | ||
| INTERFACE | ||
| ${__scope} | ||
| Boost::config | ||
| Boost::container_hash | ||
| Boost::core | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ | |
| /// 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/type_index/detail/config.hpp> | ||
|
|
||
| #include <boost/config.hpp> | ||
|
||
|
|
||
| #ifdef BOOST_HAS_PRAGMA_ONCE | ||
|
|
@@ -49,8 +51,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 +263,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,11 +18,18 @@ | |
| /// 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> | ||
| #endif | ||
|
|
||
| #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. |
||
|
|
||
| #ifdef BOOST_HAS_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,25 @@ | ||
| // | ||
| // 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 | ||
|
|
||
| #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.
Convention is
boost_type_index.cppm