random: use decltype for choose return type

This simplifies support for const-ref arguments
This commit is contained in:
Danny Robson 2020-12-14 13:08:39 +10:00
parent 60b0d1d05d
commit 3bf2c2205d

View File

@ -211,7 +211,7 @@ namespace cruft::random {
// //
/// \return An iterator to the chosen value. /// \return An iterator to the chosen value.
template <typename ContainerT, typename GeneratorT> template <typename ContainerT, typename GeneratorT>
typename ContainerT::iterator decltype(auto)
choose (ContainerT &data, GeneratorT &&gen) choose (ContainerT &data, GeneratorT &&gen)
{ {
if (data.empty ()) if (data.empty ())
@ -235,7 +235,7 @@ namespace cruft::random {
/// ///
/// \return An iterator to the chosen value. /// \return An iterator to the chosen value.
template <typename ContainerT> template <typename ContainerT>
typename ContainerT::iterator decltype(auto)
choose (ContainerT &data) choose (ContainerT &data)
{ {
return choose (data, generator ()); return choose (data, generator ());