Skip to content

Commit

Permalink
馃洜 Let the =default take care of noexcept-ness
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Jul 23, 2021
1 parent 5f81f2c commit a57714b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/ztd/ranges/subrange.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ namespace ztd { namespace ranges {
/// @brief Constructs a ztd::text::subrange containing a defaulted iterator and a defaulted sentinel.
///
//////
constexpr __subrange() noexcept = default;
constexpr __subrange() = default;

//////
/// @brief Constructs a ztd::text::subrange with its begin and end constructed by @p __range's @c begin()
Expand Down
22 changes: 14 additions & 8 deletions include/ztd/ranges/unbounded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ namespace ztd { namespace ranges {
///
/// @remarks Not very useful for anything other than generic programming shenanigans.
//////
constexpr unbounded_view() noexcept = default;
constexpr unbounded_view() = default;

//////
/// @brief Constructs an unbounded_view using the specified iterator value iterator and an infinity sentinel.
///
//////
constexpr unbounded_view(iterator __it) noexcept : _M_it(::std::move(__it)) {
constexpr unbounded_view(iterator __it) noexcept(::std::is_nothrow_move_constructible_v<iterator>)
: _M_it(::std::move(__it)) {
}

//////
Expand Down Expand Up @@ -201,7 +202,8 @@ namespace ztd { namespace ranges {
/// @remarks This function call only works if the underlying iterator and sentinal types are copyable.
//////
[[nodiscard]] constexpr unbounded_view next() const& noexcept(
::std::is_nothrow_copy_constructible_v<iterator>&& noexcept(ranges::advance(::std::declval<iterator&>()))) {
::std::is_nothrow_copy_constructible_v<iterator>&& noexcept(
ranges::advance(::std::declval<iterator&>()))) {
auto __it = this->_M_it;
ranges::advance(__it);
return unbounded_view(::std::move(__it));
Expand All @@ -214,7 +216,8 @@ namespace ztd { namespace ranges {
/// function call will move the iterators underlying this object.
//////
[[nodiscard]] constexpr unbounded_view next() && noexcept(
::std::is_nothrow_move_constructible_v<iterator>&& noexcept(ranges::advance(::std::declval<iterator&>()))) {
::std::is_nothrow_move_constructible_v<iterator>&& noexcept(
ranges::advance(::std::declval<iterator&>()))) {
iterator __it = ::std::move(this->_M_it);
ranges::advance(__it);
return unbounded_view(::std::move(__it));
Expand All @@ -228,7 +231,8 @@ namespace ztd { namespace ranges {
/// @remarks This function call only works if the underlying iterator and sentinal types are copyable.
//////
[[nodiscard]] constexpr unbounded_view next(difference_type __diff) const& noexcept(
::std::is_nothrow_copy_constructible_v<iterator>&& noexcept(ranges::advance(::std::declval<iterator&>(), __diff))) {
::std::is_nothrow_copy_constructible_v<iterator>&& noexcept(
ranges::advance(::std::declval<iterator&>(), __diff))) {
auto __it = this->_M_it;
ranges::advance(__it, __diff);
return unbounded_view(::std::move(__it));
Expand All @@ -243,7 +247,8 @@ namespace ztd { namespace ranges {
/// function call will move the iterators underlying this object.
//////
[[nodiscard]] constexpr unbounded_view next(difference_type __diff) && noexcept(
::std::is_nothrow_move_constructible_v<iterator>&& noexcept(ranges::advance(::std::declval<iterator&>(), __diff))) {
::std::is_nothrow_move_constructible_v<iterator>&& noexcept(
ranges::advance(::std::declval<iterator&>(), __diff))) {
iterator __it = ::std::move(this->_M_it);
ranges::advance(__it, __diff);
return unbounded_view(::std::move(__it));
Expand All @@ -256,8 +261,9 @@ namespace ztd { namespace ranges {
///
/// @remarks This function call requires that the underlying iterator are bidirectional.
//////
[[nodiscard]] constexpr unbounded_view prev(difference_type __diff = 1) const noexcept(
::std::is_nothrow_copy_constructible_v<iterator>&& noexcept(ranges::recede(::std::declval<iterator&>(), __diff))) {
[[nodiscard]] constexpr unbounded_view prev(difference_type __diff = 1) const
noexcept(::std::is_nothrow_copy_constructible_v<iterator>&& noexcept(
ranges::recede(::std::declval<iterator&>(), __diff))) {
auto __it = this->_M_it;
ranges::recede(__it, __diff);
return unbounded_view(::std::move(__it));
Expand Down

0 comments on commit a57714b

Please sign in to comment.