Skip to content
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

Don't provide any_view or any when static RTTI is disabled #1765

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
362 changes: 362 additions & 0 deletions .github/workflows/range-v3-ci.yml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions include/meta/meta_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,27 @@
#define META_IS_CONSTRUCTIBLE(...) std::is_constructible<__VA_ARGS__>::value
#endif

#ifndef META_HAS_STATIC_RTTI
#if defined(__cpp_rtti) || defined(__RTTI) || defined(__INTEL_RTTI__) || \
defined(__GXX_RTTI) || defined(_CPPRTTI)
#define META_HAS_STATIC_RTTI 1
#elif defined(__has_feature)
#if __has_feature(cxx_rtti)
#define META_HAS_STATIC_RTTI 1
#else
#define META_HAS_STATIC_RTTI 0
#endif
#elif defined(_MSVC_STL_VERSION)
#if _HAS_STATIC_RTTI
#define META_HAS_STATIC_RTTI 1
#else
#define META_HAS_STATIC_RTTI 0
#endif
#else
#define META_HAS_STATIC_RTTI 0
#endif
#endif

/// \cond
// Non-portable forward declarations of standard containers
#ifdef _LIBCPP_VERSION
Expand Down
4 changes: 4 additions & 0 deletions include/range/v3/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#ifndef RANGES_V3_ITERATOR_HPP
#define RANGES_V3_ITERATOR_HPP

#include <meta/meta_fwd.hpp>

#if META_HAS_STATIC_RTTI
#include <range/v3/utility/any.hpp>
#endif
#include <range/v3/utility/box.hpp>
#include <range/v3/utility/common_tuple.hpp>
#include <range/v3/utility/common_type.hpp>
Expand Down
6 changes: 6 additions & 0 deletions include/range/v3/utility/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
#ifndef RANGES_V3_UTILITY_ANY_HPP
#define RANGES_V3_UTILITY_ANY_HPP

#include <meta/meta_fwd.hpp>

#if !META_HAS_STATIC_RTTI
#error any requires static RTTI
#endif

#include <memory>
#include <type_traits>
#include <typeinfo>
Expand Down
2 changes: 2 additions & 0 deletions include/range/v3/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include <range/v3/view/adjacent_filter.hpp>
#include <range/v3/view/adjacent_remove_if.hpp>
#include <range/v3/view/all.hpp>
#if META_HAS_STATIC_RTTI
#include <range/v3/view/any_view.hpp>
#endif
#include <range/v3/view/c_str.hpp>
#include <range/v3/view/cache1.hpp>
#include <range/v3/view/cartesian_product.hpp>
Expand Down
6 changes: 6 additions & 0 deletions include/range/v3/view/any_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#ifndef RANGES_V3_VIEW_ANY_VIEW_HPP
#define RANGES_V3_VIEW_ANY_VIEW_HPP

#include <meta/meta_fwd.hpp>

#if !META_HAS_STATIC_RTTI
#error any_view requires static RTTI
#endif

#include <type_traits>
#include <typeinfo>
#include <utility>
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ add_subdirectory(experimental)
rv3_add_test(test.config config config.cpp)
rv3_add_test(test.constexpr_core constexpr_core constexpr_core.cpp)
rv3_add_test(test.multiple multiple multiple1.cpp multiple2.cpp)
if (NOT matrix.config.cxx_no_rtti EQUAL "true")
rv3_add_test(test.bug474 bug474 bug474.cpp)
endif()
rv3_add_test(test.bug566 bug566 bug566.cpp)
rv3_add_test(test.bug1322 bug1322 bug1322.cpp)
rv3_add_test(test.bug1335 bug1335 bug1335.cpp)
Expand Down
2 changes: 2 additions & 0 deletions test/view/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ set(CMAKE_FOLDER "${CMAKE_FOLDER}/view")
rv3_add_test(test.view.adaptor view.adaptor adaptor.cpp)
rv3_add_test(test.view.addressof view.addressof addressof.cpp)
rv3_add_test(test.view.adjacent_remove_if view.adjacent_remove_if adjacent_remove_if.cpp)
if (NOT matrix.config.cxx_no_rtti EQUAL "true")
rv3_add_test(test.view.all view.all all.cpp)
endif()
rv3_add_test(test.view.any_view view.any_view any_view.cpp)
rv3_add_test(test.view.common view.common common.cpp)
rv3_add_test(test.view.cache1 view.cache1 cache1.cpp)
Expand Down
4 changes: 4 additions & 0 deletions test/view/conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include <string>
#include <vector>
#include <range/v3/core.hpp>
#if META_HAS_STATIC_RTTI
#include <range/v3/view/any_view.hpp>
#endif
#include <range/v3/view/concat.hpp>
#include <range/v3/view/drop.hpp>
#include <range/v3/view/take.hpp>
Expand Down Expand Up @@ -57,6 +59,7 @@ int main()

// issue #556

#if META_HAS_STATIC_RTTI
{
std::string s{"abc"};
any_view<any_view<char, category::random_access>, category::random_access> v1 =
Expand All @@ -71,6 +74,7 @@ int main()
::check_equal(owner1, std::vector<std::vector<char>>{{'b', 'c'}, {'c'}});
::check_equal(owner2, std::vector<std::string>{{"bc"}, {"c"}});
}
#endif

// map

Expand Down