From aac5672de67798337618d0bceb93b2c799d3edc3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 27 Feb 2023 01:05:11 +0000 Subject: Add nodiscard to many collections helpers --- lib/collections.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/collections.hpp') diff --git a/lib/collections.hpp b/lib/collections.hpp index 18e6147..391647e 100644 --- a/lib/collections.hpp +++ b/lib/collections.hpp @@ -19,7 +19,7 @@ template concept IterableCollection = std::is_same_v().begin()), decltype(std::declval().end())>; template -constexpr std::array +[[nodiscard]] constexpr std::array operator+(const std::array & a, const std::array & b) { std::array r; @@ -30,7 +30,7 @@ operator+(const std::array & a, const std::array & b) } template -constexpr std::array, first * second> +[[nodiscard]] constexpr std::array, first * second> operator*(const std::array & a, const std::array & b) { std::array, first * second> r; @@ -44,7 +44,7 @@ operator*(const std::array & a, const std::array & b) } template -constexpr auto +[[nodiscard]] constexpr auto operator*(const std::array & in, auto && f) { std::array out; @@ -66,7 +66,7 @@ operator*=(std::span & in, auto && f) } template typename C, typename... T> -constexpr auto +[[nodiscard]] constexpr auto operator*(const C & in, auto && f) { C out; @@ -85,7 +85,7 @@ operator+=(std::vector & in, std::vector && src) } template -constexpr auto +[[nodiscard]] constexpr auto operator+(const std::vector & in, Vn && vn) { auto out(in); @@ -94,7 +94,7 @@ operator+(const std::vector & in, Vn && vn) } template typename Direction = std::plus> -static auto +[[nodiscard]] static auto vectorOfN(std::integral auto N, unsigned int start = {}, unsigned int step = 1) { std::vector v; @@ -106,14 +106,14 @@ vectorOfN(std::integral auto N, unsigned int start = {}, unsigned int step = 1) } template typename Rtn = std::vector, IterableCollection In> -auto +[[nodiscard]] auto materializeRange(In && in) { return Rtn(in.begin(), in.end()); } template typename Rtn = std::vector, typename In> -auto +[[nodiscard]] auto materializeRange(const std::pair & in) { return Rtn(in.first, in.second); -- cgit v1.2.3