diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-27 01:05:11 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-27 01:05:11 +0000 |
commit | aac5672de67798337618d0bceb93b2c799d3edc3 (patch) | |
tree | 1c275d0fd8e8ea9bad673e22d52785119bbf648a /lib | |
parent | Add a perf test over the asset factory (diff) | |
download | ilt-aac5672de67798337618d0bceb93b2c799d3edc3.tar.bz2 ilt-aac5672de67798337618d0bceb93b2c799d3edc3.tar.xz ilt-aac5672de67798337618d0bceb93b2c799d3edc3.zip |
Add nodiscard to many collections helpers
Diffstat (limited to 'lib')
-rw-r--r-- | lib/collections.hpp | 16 |
1 files changed, 8 insertions, 8 deletions
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<typename T> concept IterableCollection = std::is_same_v<decltype(std::declval<T>().begin()), decltype(std::declval<T>().end())>; template<typename T, std::size_t first, std::size_t second> -constexpr std::array<T, first + second> +[[nodiscard]] constexpr std::array<T, first + second> operator+(const std::array<T, first> & a, const std::array<T, second> & b) { std::array<T, first + second> r; @@ -30,7 +30,7 @@ operator+(const std::array<T, first> & a, const std::array<T, second> & b) } template<typename T, typename V, std::size_t first, std::size_t second> -constexpr std::array<std::pair<T, V>, first * second> +[[nodiscard]] constexpr std::array<std::pair<T, V>, first * second> operator*(const std::array<T, first> & a, const std::array<V, second> & b) { std::array<std::pair<T, V>, first * second> r; @@ -44,7 +44,7 @@ operator*(const std::array<T, first> & a, const std::array<V, second> & b) } template<typename T, std::size_t N> -constexpr auto +[[nodiscard]] constexpr auto operator*(const std::array<T, N> & in, auto && f) { std::array<decltype(f(in[0])), N> out; @@ -66,7 +66,7 @@ operator*=(std::span<T> & in, auto && f) } template<template<typename...> typename C, typename... T> -constexpr auto +[[nodiscard]] constexpr auto operator*(const C<T...> & in, auto && f) { C<decltype(f(in[0]))> out; @@ -85,7 +85,7 @@ operator+=(std::vector<T...> & in, std::vector<T...> && src) } template<typename... T, typename Vn> -constexpr auto +[[nodiscard]] constexpr auto operator+(const std::vector<T...> & in, Vn && vn) { auto out(in); @@ -94,7 +94,7 @@ operator+(const std::vector<T...> & in, Vn && vn) } template<template<typename> typename Direction = std::plus> -static auto +[[nodiscard]] static auto vectorOfN(std::integral auto N, unsigned int start = {}, unsigned int step = 1) { std::vector<unsigned int> v; @@ -106,14 +106,14 @@ vectorOfN(std::integral auto N, unsigned int start = {}, unsigned int step = 1) } template<template<typename...> typename Rtn = std::vector, IterableCollection In> -auto +[[nodiscard]] auto materializeRange(In && in) { return Rtn(in.begin(), in.end()); } template<template<typename...> typename Rtn = std::vector, typename In> -auto +[[nodiscard]] auto materializeRange(const std::pair<In, In> & in) { return Rtn(in.first, in.second); |