[cfe-dev] libc++, std::bind, and <random>

Seth Cantrell seth.cantrell at gmail.com
Mon Apr 11 05:33:24 PDT 2011


Here's the instantiation backtrace.

> 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);
>     ~~~ ^
> /usr/include/c++/v1/random:2117:14: note: in instantiation of function template specialization 'std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397,
>       31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::__seed<std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397,
>       31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >' requested here
>             {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
>              ^
> /usr/include/c++/v1/random:2107:10: note: in instantiation of function template specialization 'std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397,
>       31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::seed<std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31,
>       2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >' requested here
>         {seed(__q);}
>          ^
> /usr/include/c++/v1/tuple:184:15: note: in instantiation of function template specialization 'std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397,
>       31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::mersenne_twister_engine<std::__1::mersenne_twister_engine<unsigned int,
>       32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >' requested here
>             : value(_STD::forward<_Tp>(__t))
>               ^
> /usr/include/c++/v1/tuple:355:13: note: in instantiation of function template specialization 'std::__1::__tuple_leaf<0,
>       std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>,
>       false>::__tuple_leaf<std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
>       1812433253> &, void>' requested here
>             __tuple_leaf<_Uf, _Tf>(_STD::forward<_Up>(__u))...,
>             ^
> /usr/include/c++/v1/tuple:471:15: note: in instantiation of function template specialization 'std::__1::__tuple_impl<std::__1::__tuple_indices<0>,
>       std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>
>       >::__tuple_impl<0, std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
>       1812433253> , , , std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
>       1812433253> &>' requested here
>             : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
>               ^
> /usr/include/c++/v1/functional:1673:11: note: in instantiation of function template specialization
>       'std::__1::tuple<std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
>       1812433253> >::tuple<std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
>       1812433253> &, void>' requested here
>           __bound_args_(_STD::forward<_BA>(__bound_args)...) {}
>           ^
> /usr/include/c++/v1/functional:1738:12: note: in instantiation of function template specialization 'std::__1::__bind<std::__1::normal_distribution<double>,
>       std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>
>       >::__bind<std::__1::normal_distribution<double> &, std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7,
>       2636928640, 15, 4022730752, 18, 1812433253> &>' requested here
>     return type(_STD::forward<_F>(__f), _STD::forward<_BoundArgs>(__bound_args)...);
>            ^
> test.c++:7:17: note: in instantiation of function template specialization 'std::__1::bind<std::__1::normal_distribution<double> &,
>       std::__1::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> &>'
>       requested here
>     auto rand = std::bind(di,re);
>                 ^
> 1 error generated.


On Apr 11, 2011, at 1:46 AM, John McCall wrote:

> On Apr 10, 2011, at 10:18 PM, Seth Cantrell wrote:
>> Should the following work with clang and libc++?
> 
> It certainly should.
> 
>>> #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's not clear to me why this is getting instantiated and with what
> arguments.  Can you post the full instantiation backtrace, i.e. all the
> messages and not just the ultimate error?
> 
> John.





More information about the cfe-dev mailing list