Commit 4c391563 by Jonathan Wakely

libstdc++: Rename __detail::__maybe_empty_t alias template

The key property of this alias is not that it may be an empty type, but
that the type argument may not be used. The fact it's replaced by an
empty type is just an implementation detail.  The name was also
backwards with respect to the bool argument.

This patch changes the name to better reflect its purpose.

	* include/std/ranges (__detail::__maybe_empty_t): Rename to
	__maybe_present_t.
	(__adaptor::_RangeAdaptor, join_view, split_view): Use new name.
parent 005530eb
2020-03-02 Jonathan Wakely <jwakely@redhat.com> 2020-03-02 Jonathan Wakely <jwakely@redhat.com>
* include/std/ranges (__detail::__maybe_empty_t): Rename to
__maybe_present_t.
(__adaptor::_RangeAdaptor, join_view, split_view): Use new name.
* include/bits/ranges_algo.h (shift_right): Add 'typename' to * include/bits/ranges_algo.h (shift_right): Add 'typename' to
dependent type. dependent type.
......
...@@ -1030,9 +1030,14 @@ namespace __detail ...@@ -1030,9 +1030,14 @@ namespace __detail
{ {
struct _Empty { }; struct _Empty { };
template<bool _NonEmpty, typename _Tp> // Alias for a type that is conditionally present
using __maybe_empty_t = conditional_t<_NonEmpty, _Tp, _Empty>; // (and is an empty type otherwise).
// Data members using this alias should use [[no_unique_address]] so that
// they take no space when not needed.
template<bool _Present, typename _Tp>
using __maybe_present_t = conditional_t<_Present, _Tp, _Empty>;
// Alias for a type that is conditionally const.
template<bool _Const, typename _Tp> template<bool _Const, typename _Tp>
using __maybe_const_t = conditional_t<_Const, const _Tp, _Tp>; using __maybe_const_t = conditional_t<_Const, const _Tp, _Tp>;
...@@ -1065,7 +1070,7 @@ namespace views ...@@ -1065,7 +1070,7 @@ namespace views
{ {
protected: protected:
[[no_unique_address]] [[no_unique_address]]
__detail::__maybe_empty_t<!is_default_constructible_v<_Callable>, __detail::__maybe_present_t<!is_default_constructible_v<_Callable>,
_Callable> _M_callable; _Callable> _M_callable;
public: public:
...@@ -2211,8 +2216,9 @@ namespace views ...@@ -2211,8 +2216,9 @@ namespace views
static constexpr bool _S_needs_cached_begin = !random_access_range<_Vp>; static constexpr bool _S_needs_cached_begin = !random_access_range<_Vp>;
[[no_unique_address]] [[no_unique_address]]
__detail::__maybe_empty_t<_S_needs_cached_begin, __detail::__maybe_present_t<_S_needs_cached_begin,
__detail::_CachedPosition<_Vp>> _M_cached_begin; __detail::_CachedPosition<_Vp>>
_M_cached_begin;
public: public:
drop_view() = default; drop_view() = default;
...@@ -2592,7 +2598,7 @@ namespace views ...@@ -2592,7 +2598,7 @@ namespace views
// XXX: _M_inner is "present only when !is_reference_v<_InnerRange>" // XXX: _M_inner is "present only when !is_reference_v<_InnerRange>"
[[no_unique_address]] [[no_unique_address]]
__detail::__maybe_empty_t<!is_reference_v<_InnerRange>, __detail::__maybe_present_t<!is_reference_v<_InnerRange>,
views::all_t<_InnerRange>> _M_inner; views::all_t<_InnerRange>> _M_inner;
public: public:
...@@ -2728,7 +2734,7 @@ namespace views ...@@ -2728,7 +2734,7 @@ namespace views
// XXX: _M_current is present only if "V models forward_range" // XXX: _M_current is present only if "V models forward_range"
[[no_unique_address]] [[no_unique_address]]
__detail::__maybe_empty_t<forward_range<_Vp>, __detail::__maybe_present_t<forward_range<_Vp>,
iterator_t<_Base>> _M_current; iterator_t<_Base>> _M_current;
public: public:
...@@ -2969,7 +2975,7 @@ namespace views ...@@ -2969,7 +2975,7 @@ namespace views
// XXX: _M_current is "present only if !forward_range<V>" // XXX: _M_current is "present only if !forward_range<V>"
[[no_unique_address]] [[no_unique_address]]
__detail::__maybe_empty_t<!forward_range<_Vp>, iterator_t<_Vp>> __detail::__maybe_present_t<!forward_range<_Vp>, iterator_t<_Vp>>
_M_current; _M_current;
...@@ -3180,8 +3186,9 @@ namespace views ...@@ -3180,8 +3186,9 @@ namespace views
static constexpr bool _S_needs_cached_begin static constexpr bool _S_needs_cached_begin
= !common_range<_Vp> && !random_access_range<_Vp>; = !common_range<_Vp> && !random_access_range<_Vp>;
[[no_unique_address]] [[no_unique_address]]
__detail::__maybe_empty_t<_S_needs_cached_begin, __detail::__maybe_present_t<_S_needs_cached_begin,
__detail::_CachedPosition<_Vp>> _M_cached_begin; __detail::_CachedPosition<_Vp>>
_M_cached_begin;
public: public:
reverse_view() = default; reverse_view() = default;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment