Date: Sun, 29 Sep 2024 17:49:32 +0100
Hello,
Can someone please confirm if it is by design that the
std::uniform_random_bit_generator concept expects static members on
(template type) G as opposed to on (std::remove_reference_t<G>) ?
I have a use case that fails below. Passing an lvalue to bar fails, but
succeeds with foo. Foo - strips any reference from G.
https://godbolt.org/z/46WdMqhqE
```
#include <concepts>
#include <memory>
#include <random>
template< class G, class T = std::remove_reference_t<G>>
concept remove_cv_uniform_random_bit_generator =
std::invocable<G> && std::unsigned_integral<std::invoke_result_t<G>> &&
requires {
{ T::min() } -> std::same_as<std::invoke_result_t<G>>;
{ T::max() } -> std::same_as<std::invoke_result_t<G>>;
requires std::bool_constant<(T::min() < T::max())>::value;
};
template<remove_cv_uniform_random_bit_generator F>
void foo(F&& i) {
}
template<std::uniform_random_bit_generator F>
void bar(F&& i) {
}
int main()
{
static_assert(remove_cv_uniform_random_bit_generator<std::mt19937>);
static_assert(std::uniform_random_bit_generator<std::mt19937>);
std::mt19937 mt;
foo(mt);
bar(mt);//Offending line.
return 0;
} ```
If it is in fact an omission, what do you recommend to do?
Kind Regards,
Maxim Gurschi
Can someone please confirm if it is by design that the
std::uniform_random_bit_generator concept expects static members on
(template type) G as opposed to on (std::remove_reference_t<G>) ?
I have a use case that fails below. Passing an lvalue to bar fails, but
succeeds with foo. Foo - strips any reference from G.
https://godbolt.org/z/46WdMqhqE
```
#include <concepts>
#include <memory>
#include <random>
template< class G, class T = std::remove_reference_t<G>>
concept remove_cv_uniform_random_bit_generator =
std::invocable<G> && std::unsigned_integral<std::invoke_result_t<G>> &&
requires {
{ T::min() } -> std::same_as<std::invoke_result_t<G>>;
{ T::max() } -> std::same_as<std::invoke_result_t<G>>;
requires std::bool_constant<(T::min() < T::max())>::value;
};
template<remove_cv_uniform_random_bit_generator F>
void foo(F&& i) {
}
template<std::uniform_random_bit_generator F>
void bar(F&& i) {
}
int main()
{
static_assert(remove_cv_uniform_random_bit_generator<std::mt19937>);
static_assert(std::uniform_random_bit_generator<std::mt19937>);
std::mt19937 mt;
foo(mt);
bar(mt);//Offending line.
return 0;
} ```
If it is in fact an omission, what do you recommend to do?
Kind Regards,
Maxim Gurschi
Received on 2024-09-29 16:49:46