All of lore.kernel.org
 help / color / mirror / Atom feed
* shuffle_random removed in C++17 on FreeBSD/Clang??
@ 2018-01-09 10:10 Willem Jan Withagen
  2018-01-09 15:25 ` Gregory Farnum
  2018-01-09 21:22 ` Jesse Williamson
  0 siblings, 2 replies; 4+ messages in thread
From: Willem Jan Withagen @ 2018-01-09 10:10 UTC (permalink / raw)
  To: Ceph Development

Hi,

As a consequence of the move to C++17 I'm running into this problem.

--WjW

I'm getting this error:
/home/jenkins/workspace/ceph-master/src/osd/ReplicatedBackend.cc:1369:8: 
error: no member named 'random_shuffle' in namespace 'std'
   std::random_shuffle(shuffle.begin(), shuffle.end());
   ~~~~~^
1 error generated.

And the includefile tells me:
template <class RandomAccessIterator>
     void
     random_shuffle(RandomAccessIterator first, RandomAccessIterator 
last); // deprecated in C++14, removed in C++17

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: shuffle_random removed in C++17 on FreeBSD/Clang??
  2018-01-09 10:10 shuffle_random removed in C++17 on FreeBSD/Clang?? Willem Jan Withagen
@ 2018-01-09 15:25 ` Gregory Farnum
  2018-01-09 21:22 ` Jesse Williamson
  1 sibling, 0 replies; 4+ messages in thread
From: Gregory Farnum @ 2018-01-09 15:25 UTC (permalink / raw)
  To: Willem Jan Withagen; +Cc: Ceph Development

On Tue, Jan 9, 2018 at 2:10 AM, Willem Jan Withagen <wjw@digiware.nl> wrote:
> Hi,
>
> As a consequence of the move to C++17 I'm running into this problem.
>
> --WjW
>
> I'm getting this error:
> /home/jenkins/workspace/ceph-master/src/osd/ReplicatedBackend.cc:1369:8:
> error: no member named 'random_shuffle' in namespace 'std'
>   std::random_shuffle(shuffle.begin(), shuffle.end());
>   ~~~~~^
> 1 error generated.
>
> And the includefile tells me:
> template <class RandomAccessIterator>
>     void
>     random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
> // deprecated in C++14, removed in C++17

Hmm, yep! http://en.cppreference.com/w/cpp/algorithm/random_shuffle

Looks like we're just using it to re-order the list and pick a random
source, so it should be easy enough to replace with a range-restricted
integer selection. Here's a quick hack of a fix:
https://github.com/ceph/ceph/pull/19873
-Greg

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: shuffle_random removed in C++17 on FreeBSD/Clang??
  2018-01-09 10:10 shuffle_random removed in C++17 on FreeBSD/Clang?? Willem Jan Withagen
  2018-01-09 15:25 ` Gregory Farnum
@ 2018-01-09 21:22 ` Jesse Williamson
  2018-01-10  8:58   ` Willem Jan Withagen
  1 sibling, 1 reply; 4+ messages in thread
From: Jesse Williamson @ 2018-01-09 21:22 UTC (permalink / raw)
  To: Willem Jan Withagen; +Cc: Ceph Development

On Tue, 9 Jan 2018, Willem Jan Withagen wrote:

Hi Willem,

> As a consequence of the move to C++17 I'm running into this problem.

std::random_shuffle() was deprecated in C++14 and removed in C++17. Use 
std::shuffle().

The process is:

0) make a random device (ie. std::random_device)
1) make a distribution associated with that device (ie. std::mt19937)
2) shuffle!

I hope that helps,

-Jesse

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: shuffle_random removed in C++17 on FreeBSD/Clang??
  2018-01-09 21:22 ` Jesse Williamson
@ 2018-01-10  8:58   ` Willem Jan Withagen
  0 siblings, 0 replies; 4+ messages in thread
From: Willem Jan Withagen @ 2018-01-10  8:58 UTC (permalink / raw)
  To: Jesse Williamson; +Cc: Ceph Development

On 09/01/2018 22:22, Jesse Williamson wrote:
> On Tue, 9 Jan 2018, Willem Jan Withagen wrote:
> 
> Hi Willem,
> 
>> As a consequence of the move to C++17 I'm running into this problem.
> 
> std::random_shuffle() was deprecated in C++14 and removed in C++17. Use 
> std::shuffle().
> 
> The process is:
> 
> 0) make a random device (ie. std::random_device)
> 1) make a distribution associated with that device (ie. std::mt19937)
> 2) shuffle!

Yup,
That was what I found as well.
PR was submitted.

--WjW



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-10  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 10:10 shuffle_random removed in C++17 on FreeBSD/Clang?? Willem Jan Withagen
2018-01-09 15:25 ` Gregory Farnum
2018-01-09 21:22 ` Jesse Williamson
2018-01-10  8:58   ` Willem Jan Withagen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.