From f7914be11b6b1a8c5c4b0fb0b72f0558db35646e Mon Sep 17 00:00:00 2001 From: Raclamusi Date: Tue, 26 Nov 2024 18:54:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?DiscreteSample()=20=E3=81=AE=E6=88=BB?= =?UTF-8?q?=E3=82=8A=E5=80=A4=E3=81=AE=E3=82=B3=E3=83=94=E3=83=BC=E3=82=92?= =?UTF-8?q?=E5=9B=9E=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Siv3D/include/Siv3D/DiscreteDistribution.hpp | 12 ++++++------ Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Siv3D/include/Siv3D/DiscreteDistribution.hpp b/Siv3D/include/Siv3D/DiscreteDistribution.hpp index 6a0759528..5b153d35b 100644 --- a/Siv3D/include/Siv3D/DiscreteDistribution.hpp +++ b/Siv3D/include/Siv3D/DiscreteDistribution.hpp @@ -76,27 +76,27 @@ namespace s3d template [[nodiscard]] - inline auto DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight, URBG&& urbg); + inline decltype(auto) DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight, URBG&& urbg); template [[nodiscard]] - inline auto DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight); + inline decltype(auto) DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight); template [[nodiscard]] - inline auto DiscreteSample(const Container& c, DiscreteDistribution& weight, URBG&& urbg); + inline decltype(auto) DiscreteSample(const Container& c, DiscreteDistribution& weight, URBG&& urbg); template [[nodiscard]] - inline auto DiscreteSample(const Container& c, DiscreteDistribution& weight); + inline decltype(auto) DiscreteSample(const Container& c, DiscreteDistribution& weight); template [[nodiscard]] - inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg); + inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg); template [[nodiscard]] - inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight); + inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight); } # include "detail/DiscreteDistribution.ipp" diff --git a/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp b/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp index ec89850d5..aaf61c37f 100644 --- a/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp +++ b/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp @@ -73,7 +73,7 @@ namespace s3d } template - inline auto DiscreteSample(Iterator begin, [[maybe_unused]] Iterator end, DiscreteDistribution& weight, URBG&& urbg) + inline decltype(auto) DiscreteSample(Iterator begin, [[maybe_unused]] Iterator end, DiscreteDistribution& weight, URBG&& urbg) { assert(begin != end); assert(std::distance(begin, end) == static_cast(weight.size())); @@ -83,13 +83,13 @@ namespace s3d } template - inline auto DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight) + inline decltype(auto) DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight) { return DiscreteSample(begin, end, weight, GetDefaultRNG()); } template - inline auto DiscreteSample(const Container& c, DiscreteDistribution& weight, URBG&& urbg) + inline decltype(auto) DiscreteSample(const Container& c, DiscreteDistribution& weight, URBG&& urbg) { assert(std::size(c) != 0); assert(std::size(c) == weight.size()); @@ -100,20 +100,20 @@ namespace s3d } template - inline auto DiscreteSample(const Container& c, DiscreteDistribution& weight) + inline decltype(auto) DiscreteSample(const Container& c, DiscreteDistribution& weight) { return DiscreteSample(c, weight, GetDefaultRNG()); } template - inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg) + inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg) { assert(ilist.size() != 0); return *(ilist.begin() + weight(std::forward(urbg))); } template - inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight) + inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight) { return DiscreteSample(ilist, weight, GetDefaultRNG()); } From 340466bbf2f4441bd9cf2409f499ea4c6df2639e Mon Sep 17 00:00:00 2001 From: Raclamusi Date: Wed, 27 Nov 2024 01:30:46 +0900 Subject: [PATCH 2/2] =?UTF-8?q?std::initializer=5Flist=20=E3=82=92?= =?UTF-8?q?=E5=8F=96=E3=82=8B=E3=82=AA=E3=83=BC=E3=83=90=E3=83=BC=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=AE=E6=88=BB=E3=82=8A=E5=80=A4=E3=82=92?= =?UTF-8?q?=20auto=20=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Siv3D/include/Siv3D/DiscreteDistribution.hpp | 4 ++-- Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Siv3D/include/Siv3D/DiscreteDistribution.hpp b/Siv3D/include/Siv3D/DiscreteDistribution.hpp index 5b153d35b..e87a841b6 100644 --- a/Siv3D/include/Siv3D/DiscreteDistribution.hpp +++ b/Siv3D/include/Siv3D/DiscreteDistribution.hpp @@ -92,11 +92,11 @@ namespace s3d template [[nodiscard]] - inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg); + inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg); template [[nodiscard]] - inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight); + inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight); } # include "detail/DiscreteDistribution.ipp" diff --git a/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp b/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp index aaf61c37f..1fb298f72 100644 --- a/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp +++ b/Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp @@ -106,14 +106,14 @@ namespace s3d } template - inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg) + inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight, URBG&& urbg) { assert(ilist.size() != 0); return *(ilist.begin() + weight(std::forward(urbg))); } template - inline decltype(auto) DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight) + inline auto DiscreteSample(std::initializer_list ilist, DiscreteDistribution& weight) { return DiscreteSample(ilist, weight, GetDefaultRNG()); }