Date: Sat, 5 Oct 2024 22:18:04 +0100
Thank you Yongwei,
That clears up the observation.
On 30 Sep 2024, at 04:50, Yongwei Wu <wuyongwei_at_[hidden]> wrote:
Kind Regards,
Maxim Gurschi
On 30 Sep 2024, at 04:50, Yongwei Wu <wuyongwei_at_[hidden]> wrote:
--
I'd guess it is neither by design nor a bug. It is simply the result of current rules, and is potentially a design flaw (or an ease-of-use bug). It occurs not only with uniform_random_bit_generator, but all kinds of other concepts when used with auto&&.
The current easy way of achieving your purpose is probably avoiding the abbreviated syntax:
template <typename G>
requires std::uniform_random_bit_generator<std::remove_cvref_t<G>>
void bar(G&& i)
…
Please also notice that using remove_reference_t is probably not good enough.
On Mon, 30 Sept 2024 at 00:49, M Gurschi via Std-Discussion <std-discussion_at_[hidden]> wrote:
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
Std-Discussion mailing list
Std-Discussion_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
--
Yongwei Wu
URL: http://wyw.dcweb.cn/
URL: http://wyw.dcweb.cn/
Received on 2024-10-05 21:18:16