Skip to content
63 changes: 0 additions & 63 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -397,39 +397,6 @@ namespace ranges {
};

inline constexpr _For_each_n_fn for_each_n{_Not_quite_object::_Construct_tag{}};

// VARIABLE ranges::find
class _Find_fn : private _Not_quite_object {
public:
using _Not_quite_object::_Not_quite_object;

// clang-format off
template <input_iterator _It, sentinel_for<_It> _Se, class _Ty, class _Pj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<_It, _Pj>, const _Ty*>
_NODISCARD constexpr _It operator()(_It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const {
_Adl_verify_range(_First, _Last);
auto _UResult = _RANGES _Find_unchecked(
_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Val, _Pass_fn(_Proj));
Comment on lines -411 to -412

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not get why we are pulling those algorithms out. We do not really want the bounds checks and we already have the unchecked iterators ready.

Why not simply call _RANGES _Find_unchecked and _RANGES _Copy_unchecked ?

@CaseyCarter Casey Carter (CaseyCarter) Apr 9, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For calling directly with range arguments when we don't have iterators handy, it's much simpler to call the range algorithm. (Recall that Range algorithms with range arguments don't perform bounds checks - they trust that begin() and end() return a valid range.)


_Seek_wrapped(_First, _STD move(_UResult));
return _First;
}

template <input_range _Rng, class _Ty, class _Pj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rng>, _Pj>, const _Ty*>
_NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(
_Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const {
auto _First = _RANGES begin(_Range);
auto _UResult =
_RANGES _Find_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _Val, _Pass_fn(_Proj));

_Seek_wrapped(_First, _STD move(_UResult));
return _First;
}
// clang-format on
};

inline constexpr _Find_fn find{_Not_quite_object::_Construct_tag{}};
} // namespace ranges
#endif // __cpp_lib_concepts

Expand Down Expand Up @@ -1380,36 +1347,6 @@ namespace ranges {

inline constexpr _None_of_fn none_of{_Not_quite_object::_Construct_tag{}};

// VARIABLE ranges::copy
class _Copy_fn : private _Not_quite_object {
public:
using _Not_quite_object::_Not_quite_object;

// clang-format off
template <input_iterator _It, sentinel_for<_It> _Se, weakly_incrementable _Out>
requires indirectly_copyable<_It, _Out>
constexpr copy_result<_It, _Out> operator()(_It _First, _Se _Last, _Out _Result) const {
_Adl_verify_range(_First, _Last);
auto _UResult = _RANGES _Copy_unchecked(
_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _STD move(_Result));
_Seek_wrapped(_First, _STD move(_UResult.in));
return {_STD move(_First), _STD move(_UResult.out)};
}

template <input_range _Rng, weakly_incrementable _Out>
requires indirectly_copyable<iterator_t<_Rng>, _Out>
constexpr copy_result<borrowed_iterator_t<_Rng>, _Out> operator()(_Rng&& _Range, _Out _Result) const {
auto _First = _RANGES begin(_Range);
auto _UResult =
_RANGES _Copy_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _STD move(_Result));
_Seek_wrapped(_First, _STD move(_UResult.in));
return {_STD move(_First), _STD move(_UResult.out)};
}
// clang-format on
};

inline constexpr _Copy_fn copy{_Not_quite_object::_Construct_tag{}};

// ALIAS TEMPLATE copy_n_result
template <class _In, class _Out>
using copy_n_result = in_out_result<_In, _Out>;
Expand Down
15 changes: 8 additions & 7 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -5195,8 +5195,8 @@ namespace chrono {

template <class _CharT>
struct _Chrono_specs {
_CharT _Lit_char = _CharT{0}; // any char other than {, }, %
char _Modifier = '\0'; // either E or O
_CharT _Lit_char = _CharT{0}; // any character other than '{', '}', or '%'
char _Modifier = '\0'; // either 'E' or 'O'
char _Type = '\0';
};

Expand All @@ -5208,7 +5208,7 @@ namespace chrono {
int _Dynamic_precision_index = -1;
_Align _Alignment = _Align::_None;
// At most one codepoint (so one char32_t or four utf-8 char8_t)
_CharT _Fill[4] = {' ', _CharT{0}, _CharT{0}, _CharT{0}};
_CharT _Fill[4 / sizeof(_CharT)] = {_CharT{' '}};
// recursive definition in grammar, so could have any number of these with literal chars
vector<_Chrono_specs<_CharT>> _Chrono_specs_list;
};
Expand All @@ -5226,12 +5226,12 @@ namespace chrono {

// same as _Specs_setter
constexpr void _On_fill(basic_string_view<_CharT> _Sv) {
if (_Sv.size() > 4) {
if (_Sv.size() > _STD size(_Specs._Fill)) {
_THROW(format_error("Invalid fill (too long)."));
}

_STD fill(_Specs._Fill, _Specs._Fill + 4, _CharT{});
_STD copy(_Sv.begin(), _Sv.end(), _Specs._Fill);
const auto _Pos = _STD _Copy_unchecked(_Sv._Unchecked_begin(), _Sv._Unchecked_end(), _Specs._Fill);
_STD fill(_Pos, _STD end(_Specs._Fill), _CharT{});
}

constexpr void _On_width(int _Width) {
Expand Down Expand Up @@ -5270,7 +5270,8 @@ namespace chrono {
template <class _CharT, _Chrono_parse_spec_callbacks<_CharT> _Callbacks_type>
_NODISCARD constexpr const _CharT* _Parse_conversion_specs(
const _CharT* _Begin, const _CharT* _End, _Callbacks_type&& _Callbacks) {
++_Begin; // move past %
_STL_INTERNAL_CHECK(*_Begin == '%');
++_Begin;
if (_Begin == _End || *_Begin == '}') {
_THROW(format_error("Invalid format string."));
}
Expand Down
Loading