Skip to content

Commit

Permalink
DiscreteSample() の戻り値のコピーを回避 (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raclamusi authored Nov 28, 2024
1 parent 458bec9 commit 53a103e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Siv3D/include/Siv3D/DiscreteDistribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ namespace s3d

template <class Iterator, class URBG>
[[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 <class Iterator>
[[nodiscard]]
inline auto DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight);
inline decltype(auto) DiscreteSample(Iterator begin, Iterator end, DiscreteDistribution& weight);

template <class Container, class URBG>
[[nodiscard]]
inline auto DiscreteSample(const Container& c, DiscreteDistribution& weight, URBG&& urbg);
inline decltype(auto) DiscreteSample(const Container& c, DiscreteDistribution& weight, URBG&& urbg);

template <class Container>
[[nodiscard]]
inline auto DiscreteSample(const Container& c, DiscreteDistribution& weight);
inline decltype(auto) DiscreteSample(const Container& c, DiscreteDistribution& weight);

template <class Type, class URBG>
[[nodiscard]]
Expand Down
8 changes: 4 additions & 4 deletions Siv3D/include/Siv3D/detail/DiscreteDistribution.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace s3d
}

template <class Iterator, class URBG>
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<int64>(weight.size()));
Expand All @@ -83,13 +83,13 @@ namespace s3d
}

template <class Iterator>
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 <class Container, class URBG>
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());
Expand All @@ -100,7 +100,7 @@ namespace s3d
}

template <class Container>
inline auto DiscreteSample(const Container& c, DiscreteDistribution& weight)
inline decltype(auto) DiscreteSample(const Container& c, DiscreteDistribution& weight)
{
return DiscreteSample(c, weight, GetDefaultRNG());
}
Expand Down

0 comments on commit 53a103e

Please sign in to comment.