From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5673 invoked by alias); 12 Apr 2017 05:01:46 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 4038 invoked by uid 89); 12 Apr 2017 05:01:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: laurel.swan.ac.uk Received: from laurel.swan.ac.uk (HELO laurel.swan.ac.uk) (137.44.100.6) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Apr 2017 05:01:38 +0000 Received: from [137.44.60.177] (helo=hub.tawe.swan.ac.uk) by laurel.swan.ac.uk with esmtp (Exim 4.87) (envelope-from ) id 1cyAPR-00073O-K8; Wed, 12 Apr 2017 06:01:37 +0100 Received: from csltok.swansea.ac.uk (137.44.60.123) by ISS-BAYEXCH2.tawe.swan.ac.uk (137.44.60.177) with Microsoft SMTP Server (TLS) id 15.1.396.30; Wed, 12 Apr 2017 06:01:34 +0100 Date: Wed, 12 Apr 2017 05:01:00 -0000 From: Oliver Kullmann To: Jonathan Wakely CC: Martin Sebor , gcc-help Subject: Re: where are the implementations for ? Message-ID: <20170412050132.GA22350@csltok.swansea.ac.uk> References: <20170409173101.GA10474@csltok.swansea.ac.uk> <5277517b-1722-17b2-a33c-9abe6d625c0a@gmail.com> <20170411130242.GA7454@csltok.swansea.ac.uk> <20170411182615.GA16536@csltok.swansea.ac.uk> <20170411201729.GA18654@csltok.swansea.ac.uk> <20170412034030.GA20421@csltok.swansea.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170412034030.GA20421@csltok.swansea.ac.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-ClientProxiedBy: ISS-BAYEXCH1.tawe.swan.ac.uk (137.44.60.176) To ISS-BAYEXCH2.tawe.swan.ac.uk (137.44.60.177) X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00060.txt.bz2 I found http://eel.is/c++draft/rand.eng.mers which, if it has been adopted by the Standard, seems in Points 6, 8 actually to fully specify the seeding, from initial values as well as from sequents (std::seed_seq), and thus, hopefully, actually seeding in both forms seems well-defined by the standard. (Otherwise it would be a strange oversight.) Oliver P.S. And it seems that the GCC implementation does what is described in that document. > Consider the following program MT.cpp: > > #include > #include > #include > #include > > int main() { > typedef std::mt19937_64::result_type ui; > std::seed_seq s {ui(10),ui(10),ui(0)}; > std::vector seeds(3); > s.generate(seeds.begin(), seeds.end()); > for (const auto x : seeds) std::cout << x << " "; > std::cout << "\n"; > std::mt19937_64 g(s); > std::cout << g() << " " << g() << "\n"; > } > > Compiled with > > g++ --std=c++11 -Wall MT.cpp > it yields with gcc 4.7.4 and gcc 5.4 > > > ./a.out > 927367489 2598207009 681269367 > 14538134740155241067 15440504459514664889 > > As far as I understand it, only the first line is defined by the standard, > but not the second: how the seed-sequence is used by the generator g is up > to the compiler. > > Thus the need to do the seeding ourselves. > > Oliver >