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

DiscreteSample() の戻り値のコピーを回避 #1275

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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