From: Jonathan Wakely Date: Mon, 17 Feb 2020 15:25:33 +0000 (+0000) Subject: libstdc++: Reduce header dependencies for C++20 (PR 92546) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9cd4eeefcc641dd70d026e08e9d218101b826c52;p=gcc.git libstdc++: Reduce header dependencies for C++20 (PR 92546) In C++20 depends on which depends on just for a single concept. Including also requires including , which is huge due to the C++17 special functions. This change moves the concept to the internal header that exists so that doesn't need to include . PR libstdc++/92546 (partial) * include/bits/random.h (uniform_random_bit_generator): Move definition to . * include/bits/ranges_algo.h: Include instead of . * include/bits/ranges_algobase.h: Do not include . * include/bits/uniform_int_dist.h (uniform_random_bit_generator): Move here. * include/std/ranges: Do not include . * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error lineno. --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 954eb673184..f4477aaa6f2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,16 @@ 2020-02-17 Jonathan Wakely + PR libstdc++/92546 (partial) + * include/bits/random.h (uniform_random_bit_generator): Move definition + to . + * include/bits/ranges_algo.h: Include instead + of . + * include/bits/ranges_algobase.h: Do not include . + * include/bits/uniform_int_dist.h (uniform_random_bit_generator): + Move here. + * include/std/ranges: Do not include . + * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error lineno. + PR libstdc++/92546 (partial) * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index d4aebf45af0..19307fbc3ca 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -33,9 +33,6 @@ #include #include -#if __cplusplus > 201703L -# include -#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -51,18 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ -#ifdef __cpp_lib_concepts - /// Requirements for a uniform random bit generator. - template - concept uniform_random_bit_generator - = invocable<_Gen&> && unsigned_integral> - && requires - { - { _Gen::min() } -> same_as>; - { _Gen::max() } -> same_as>; - requires bool_constant<(_Gen::min() < _Gen::max())>::value; - }; -#endif + // std::uniform_random_bit_generator is defined in /** * @brief A function template for converting the output of a (integral) diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index ff1b40f6ace..f3a349ef839 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -33,7 +33,7 @@ #if __cplusplus > 201703L #include -#include // concept uniform_random_bit_generator +#include // concept uniform_random_bit_generator #if __cpp_lib_concepts namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/bits/ranges_algobase.h b/libstdc++-v3/include/bits/ranges_algobase.h index cc24483b2d3..eedd29f570a 100644 --- a/libstdc++-v3/include/bits/ranges_algobase.h +++ b/libstdc++-v3/include/bits/ranges_algobase.h @@ -32,7 +32,6 @@ #if __cplusplus > 201703L -#include #include #include // #include diff --git a/libstdc++-v3/include/bits/uniform_int_dist.h b/libstdc++-v3/include/bits/uniform_int_dist.h index d2a01570635..e3d7934e997 100644 --- a/libstdc++-v3/include/bits/uniform_int_dist.h +++ b/libstdc++-v3/include/bits/uniform_int_dist.h @@ -33,11 +33,27 @@ #include #include +#if __cplusplus > 201703L +# include +#endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#ifdef __cpp_lib_concepts + /// Requirements for a uniform random bit generator. + template + concept uniform_random_bit_generator + = invocable<_Gen&> && unsigned_integral> + && requires + { + { _Gen::min() } -> same_as>; + { _Gen::max() } -> same_as>; + requires bool_constant<(_Gen::min() < _Gen::max())>::value; + }; +#endif + namespace __detail { /* Determine whether number is a power of 2. */ diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 970e904bddd..b9ac528fdff 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -42,7 +42,6 @@ #include #include #include -#include #include #include diff --git a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc index 91e5566c54a..f808132e9ea 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc @@ -10,6 +10,6 @@ std::__detail::_Adaptor aurng(urng); auto x = std::generate_canonical::digits>(urng); -// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 172 } +// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 158 } // { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3281 }