[cfe-dev] libc++, std::bind, and <random>
Howard Hinnant
hhinnant at apple.com
Mon Apr 11 08:38:36 PDT 2011
On Apr 11, 2011, at 11:30 AM, Steven Watanabe wrote:
> AMDG
>
> On 04/10/2011 10:18 PM, Seth Cantrell wrote:
>> Should the following work with clang and libc++?
>>
>>> #include<functional>
>>> #include<random>
>>>
>>> int main(int argc,char const *argv[]) {
>>> std::mt19937 re;
>>> std::normal_distribution<> di(30,8);
>>> auto rand = std::bind(di,re);
>>> }
>>
>> Clang outputs the following error for this program:
>>
>>> In file included from test.c++:2:
>>> /usr/include/c++/v1/random:2234:9: error: no member named 'generate' in 'std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11,
>>> 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>'
>>> __q.generate(__ar, __ar + __n * __k);
>>> ~~~ ^
>>
>> It looks to me like clang supports all the features necessary, and the code runs as expected in VS2010. Here's the command line I used:
>>
>
> When calling the copy constructor of a Random
> Number Engine with a non-const argument, the library is
> incorrectly treating the argument as a SeedSeq.
> The two declarations in question are:
>
> mersenne_twister(const mersenne_twister&);
> template<typename SeedSeq> mersenne_twister(SeedSeq&);
Thanks Steven. I'm working on an improved constraint for the SeedSeq template parameter. The current constraint is simply that it is not implicitly convertible to the engine's result_type.
Howard
More information about the cfe-dev
mailing list