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

Add [[nodiscard]] to algorithms and views #106

Open
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/adjacent_find.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct adjacent_find_fn {
public:
template <typename I, typename S, typename Proj = identity,
typename Pred = ranges::equal_to>
constexpr std::enable_if_t<forward_iterator<I> && sentinel_for<S, I> &&
[[nodiscard]] constexpr std::enable_if_t<forward_iterator<I> && sentinel_for<S, I> &&
indirect_relation<Pred, projected<I, Proj>>,
I>
operator()(I first, S last, Pred pred = Pred{}, Proj proj = Proj{}) const
Expand All @@ -55,7 +55,7 @@ struct adjacent_find_fn {

template <typename Rng, typename Proj = identity,
typename Pred = ranges::equal_to>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_range<Rng> &&
indirect_relation<Pred, projected<iterator_t<Rng>, Proj>>,
borrowed_iterator_t<Rng>>
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/all_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct all_of_fn {

public:
template <typename I, typename S, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_unary_predicate<Pred, projected<I, Proj>>,
bool>
Expand All @@ -42,7 +42,7 @@ struct all_of_fn {
}

template <typename Rng, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>,
bool>
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/any_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct any_of_fn {

public:
template <typename I, typename S, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_unary_predicate<Pred, projected<I, Proj>>,
bool>
Expand All @@ -45,7 +45,7 @@ struct any_of_fn {
}

template <typename Rng, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>,
bool>
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/binary_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct binary_search_fn {
public:
template <typename I, typename S, typename T, typename Comp = ranges::less,
typename Proj = identity>
std::enable_if_t<
[[nodiscard]] std::enable_if_t<
forward_iterator<I> && sentinel_for<S, I> &&
indirect_strict_weak_order<Comp, const T*, projected<I, Proj>>,
bool>
Expand All @@ -39,7 +39,7 @@ struct binary_search_fn {

template <typename Rng, typename T, typename Comp = ranges::less,
typename Proj = identity>
std::enable_if_t<forward_range<Rng> &&
[[nodiscard]] std::enable_if_t<forward_range<Rng> &&
indirect_strict_weak_order<Comp, const T*, projected<iterator_t<Rng>, Proj>>,
bool>
constexpr operator()(Rng&& rng, const T& value, Comp comp = Comp{},
Expand Down
2 changes: 1 addition & 1 deletion include/nanorange/algorithm/clamp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace detail {

struct clamp_fn {
template <typename T, typename Proj = identity, typename Comp = nano::less>
constexpr std::enable_if_t<indirect_strict_weak_order<Comp, projected<const T*, Proj>>, const T&>
[[nodiscard]] constexpr std::enable_if_t<indirect_strict_weak_order<Comp, projected<const T*, Proj>>, const T&>
operator()(const T& value, const T& low, const T& high, Comp comp = {}, Proj proj = Proj{}) const
{
auto&& projected_value = nano::invoke(proj, value);
Expand Down
8 changes: 4 additions & 4 deletions include/nanorange/algorithm/count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct count_if_fn {

public:
template <typename I, typename S, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_unary_predicate<Pred, projected<I, Proj>>,
iter_difference_t<I>>
Expand All @@ -48,7 +48,7 @@ struct count_if_fn {
}

template <typename Rng, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>,
range_difference_t<Rng>>
Expand All @@ -66,7 +66,7 @@ namespace detail {

struct count_fn {
template <typename I, typename S, typename T, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_relation<ranges::equal_to, projected<I, Proj>, const T*>,
iter_difference_t<I>>
Expand All @@ -78,7 +78,7 @@ struct count_fn {
}

template <typename Rng, typename T, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_relation<ranges::equal_to, projected<iterator_t<Rng>, Proj>,
const T*>,
Expand Down
8 changes: 4 additions & 4 deletions include/nanorange/algorithm/equal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct equal_fn {
template <typename I1, typename S1, typename I2, typename S2,
typename Pred = ranges::equal_to, typename Proj1 = identity,
typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I1> && sentinel_for<S1, I1> && input_iterator<I2> &&
sentinel_for<S2, I2> &&
indirectly_comparable<I1, I2, Pred, Proj1, Proj2> &&
Expand All @@ -79,7 +79,7 @@ struct equal_fn {
template <typename I1, typename S1, typename I2, typename S2,
typename Pred = ranges::equal_to, typename Proj1 = identity,
typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I1> && sentinel_for<S1, I1> && input_iterator<I2> &&
sentinel_for<S2, I2> &&
indirectly_comparable<I1, I2, Pred, Proj1, Proj2> &&
Expand Down Expand Up @@ -112,7 +112,7 @@ struct equal_fn {
// Two ranges, both sized
template <typename Rng1, typename Rng2, typename Pred = ranges::equal_to,
typename Proj1 = identity, typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng1> && input_range<Rng2> &&
indirectly_comparable<iterator_t<Rng1>, iterator_t<Rng2>, Pred,
Proj1, Proj2> &&
Expand All @@ -132,7 +132,7 @@ struct equal_fn {
// Two ranges, not both sized
template <typename Rng1, typename Rng2, typename Pred = ranges::equal_to,
typename Proj1 = identity, typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng1> && input_range<Rng2> &&
indirectly_comparable<iterator_t<Rng1>, iterator_t<Rng2>, Pred,
Proj1, Proj2> &&
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/equal_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct equal_range_fn {
public:
template <typename I, typename S, typename T, typename Comp = ranges::less,
typename Proj = identity>
std::enable_if_t<
[[nodiscard]] std::enable_if_t<
forward_iterator<I> && sentinel_for<S, I> &&
indirect_strict_weak_order<Comp, const T*, projected<I, Proj>>,
subrange<I>>
Expand All @@ -41,7 +41,7 @@ struct equal_range_fn {

template <typename Rng, typename T, typename Comp = ranges::less,
typename Proj = identity>
std::enable_if_t<forward_range<Rng> &&
[[nodiscard]] std::enable_if_t<forward_range<Rng> &&
indirect_strict_weak_order<Comp, const T*, projected<iterator_t<Rng>, Proj>>,
borrowed_subrange_t<Rng>>
constexpr operator()(Rng&& rng, const T& value, Comp comp = Comp{},
Expand Down
12 changes: 6 additions & 6 deletions include/nanorange/algorithm/find.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct find_if_fn {

public:
template <typename I, typename S, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_unary_predicate<Pred, projected<I, Proj>>,
I>
Expand All @@ -44,7 +44,7 @@ struct find_if_fn {
}

template <typename Rng, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>,
borrowed_iterator_t<Rng>>
Expand All @@ -61,7 +61,7 @@ namespace detail {

struct find_fn {
template <typename I, typename S, typename T, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_relation<ranges::equal_to, projected<I, Proj>, const T*>,
I>
Expand All @@ -72,7 +72,7 @@ struct find_fn {
}

template <typename Rng, typename T, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_relation<ranges::equal_to, projected<iterator_t<Rng>, Proj>,
const T*>,
Expand Down Expand Up @@ -104,7 +104,7 @@ struct find_if_not_fn {

public:
template <typename I, typename S, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_unary_predicate<Pred, projected<I, Proj>>,
I>
Expand All @@ -116,7 +116,7 @@ struct find_if_not_fn {
}

template <typename Rng, typename Proj = identity, typename Pred>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>,
borrowed_iterator_t<Rng>>
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/find_end.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct find_end_fn {
template <typename I1, typename S1, typename I2, typename S2,
typename Pred = ranges::equal_to, typename Proj1 = identity,
typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_iterator<I1> && sentinel_for<S1, I1> && forward_iterator<I2> &&
sentinel_for<S2, I2> &&
indirectly_comparable<I1, I2, Pred, Proj1, Proj2>,
Expand All @@ -65,7 +65,7 @@ struct find_end_fn {

template <typename Rng1, typename Rng2, typename Pred = ranges::equal_to,
typename Proj1 = identity, typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_range<Rng1> && forward_range<Rng2> &&
indirectly_comparable<iterator_t<Rng1>, iterator_t<Rng2>, Pred, Proj1, Proj2>,
borrowed_subrange_t<Rng1>>
Expand Down
6 changes: 3 additions & 3 deletions include/nanorange/algorithm/find_first_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct find_first_of_fn {
template <typename I1, typename S1, typename I2, typename S2,
typename Proj1 = identity, typename Proj2 = identity,
typename Pred = ranges::equal_to>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I1> && sentinel_for<S1, I1> && forward_iterator<I2> &&
sentinel_for<S2, I2> &&
indirect_relation<Pred, projected<I1, Proj1>, projected<I2, Proj2>>,
Expand All @@ -53,7 +53,7 @@ struct find_first_of_fn {

template <typename Rng1, typename Rng2, typename Proj1 = identity,
typename Proj2 = identity, typename Pred = ranges::equal_to>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng1> && forward_range<Rng2> &&
indirect_relation<Pred, projected<iterator_t<Rng1>, Proj1>,
projected<iterator_t<Rng2>, Proj2>>,
Expand All @@ -73,4 +73,4 @@ NANO_INLINE_VAR(detail::find_first_of_fn, find_first_of)

NANO_END_NAMESPACE

#endif
#endif
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct includes_fn {
public:
template <typename I1, typename S1, typename I2, typename S2,
typename Comp = ranges::less, typename Proj1 = identity, typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I1> && sentinel_for<S1, I1> && input_iterator<I2> &&
sentinel_for<S2, I2> &&
indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>,
Expand All @@ -66,7 +66,7 @@ struct includes_fn {

template <typename Rng1, typename Rng2, typename Comp = ranges::less,
typename Proj1 = identity, typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng1> && input_range<Rng2> &&
indirect_strict_weak_order<Comp,
projected<iterator_t<Rng1>, Proj1>,
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/is_heap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace detail {
struct is_heap_fn {
template <typename I, typename S, typename Comp = ranges::less,
typename Proj = identity>
std::enable_if_t<random_access_iterator<I> && sentinel_for<S, I> &&
[[nodiscard]] std::enable_if_t<random_access_iterator<I> && sentinel_for<S, I> &&
indirect_strict_weak_order<Comp, projected<I, Proj>>,
bool>
operator()(I first, S last, Comp comp = Comp{}, Proj proj = Proj{}) const
Expand All @@ -26,7 +26,7 @@ struct is_heap_fn {
}

template <typename Rng, typename Comp = ranges::less, typename Proj = identity>
std::enable_if_t<
[[nodiscard]] std::enable_if_t<
random_access_range<Rng> &&
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>,
bool>
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/is_heap_until.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct is_heap_until_fn {
public:
template <typename I, typename S, typename Comp = ranges::less,
typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
random_access_iterator<I> && sentinel_for<S, I> &&
indirect_strict_weak_order<Comp, projected<I, Proj>>,
I>
Expand All @@ -69,7 +69,7 @@ struct is_heap_until_fn {
}

template <typename Rng, typename Comp = ranges::less, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
random_access_range<Rng> &&
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>,
borrowed_iterator_t<Rng>>
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/is_partitioned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct is_partitioned_fn {

public:
template <typename I, typename S, typename Pred, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_iterator<I> && sentinel_for<S, I> &&
indirect_unary_predicate<Pred, projected<I, Proj>>, bool>
operator()(I first, S last, Pred pred = Pred{}, Proj proj = Proj{}) const
Expand All @@ -34,7 +34,7 @@ struct is_partitioned_fn {
}

template <typename Rng, typename Pred, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
input_range<Rng> &&
indirect_unary_predicate<Pred, projected<iterator_t<Rng>, Proj>>, bool>
operator()(Rng&& rng, Pred pred = Pred{}, Proj proj = Proj{}) const
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/is_permutation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct is_permutation_fn {
template <typename I1, typename S1, typename I2, typename S2,
typename Pred = ranges::equal_to, typename Proj1 = identity,
typename Proj2 = identity>
constexpr
[[nodiscard]] constexpr
std::enable_if_t<
forward_iterator<I1> && sentinel_for<S1, I1> && forward_iterator<I2> &&
sentinel_for<S2, I2> &&
Expand Down Expand Up @@ -160,7 +160,7 @@ struct is_permutation_fn {
// Two ranges
template <typename Rng1, typename Rng2, typename Pred = ranges::equal_to,
typename Proj1 = identity, typename Proj2 = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_range<Rng1> && forward_range<Rng2> &&
indirectly_comparable<iterator_t<Rng1>, iterator_t<Rng2>, Pred,
Proj1, Proj2>,
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/is_sorted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace detail {
struct is_sorted_fn {
template <typename I, typename S, typename Comp = ranges::less,
typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_iterator<I> && sentinel_for<S, I> &&
indirect_strict_weak_order<Comp, projected<I, Proj>>, bool>
operator()(I first, S last, Comp comp = Comp{}, Proj proj = Proj{}) const
Expand All @@ -26,7 +26,7 @@ struct is_sorted_fn {
}

template <typename Rng, typename Comp = ranges::less, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_range<Rng> &&
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>,
bool>
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/is_sorted_until.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct is_sorted_until_fn {
public:
template <typename I, typename S, typename Comp = ranges::less,
typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_iterator<I> && sentinel_for<S, I> &&
indirect_strict_weak_order<Comp, projected<I, Proj>>, I>
operator()(I first, S last, Comp comp = Comp{}, Proj proj = Proj{}) const
Expand All @@ -51,7 +51,7 @@ struct is_sorted_until_fn {
}

template <typename Rng, typename Comp = ranges::less, typename Proj = identity>
constexpr std::enable_if_t<
[[nodiscard]] constexpr std::enable_if_t<
forward_range<Rng> &&
indirect_strict_weak_order<Comp, projected<iterator_t<Rng>, Proj>>,
borrowed_iterator_t<Rng>>
Expand Down