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