std::seed_seq::seed_seq(3)
π std::seed_seq::seed_seq(3) π
okay so this is the constructor page for std::seed_seq, straight from the C++ Standard Libary manual (yes, that's how the header spells it β their typo, not mine π
). It's giving tiny-but-important seed energy, and we're keeping every single detail exactly where it belongs. Obsessed, honestly.
πΈ NAME πΈ
std::seed_seq::seed_seq β the constructor for std::seed_seq itself. The page literally says std::seed_seq::seed_seq - std::seed_seq::seed_seq, and that self-reference is iconic. Periodt.
β¨ Synopsis β¨
seed_seq() noexcept; (1) (since C++11)
seed_seq( const seed_seq& ) = delete; (2) (since C++11)
template< class InputIt > (3) (since C++11)
seed_seq( InputIt begin, InputIt end );
template< class T > (4) (since C++11)
seed_seq( std::initializer_list<T> il );
- The default constructor creates a
std::seed_seqobject with an initial seed sequence of length zero. Empty. Blank. A fresh start, no cap. - The copy constructor is deleted:
std::seed_seqis not copyable. You cannot duplicate this icon, bestie. - Constructs a
std::seed_seqwith the initial seed sequence obtained by iterating over the range[begin, end)and copying the values obtained by dereferencing the iterator,modulo 232β and the page clarifies that this means the lower 32 bits are copied. - Equivalent to
seed_seq(il.begin(), il.end()). This constructor enables list-initialization from the list of seed values. This overload participates in overload resolution only ifTis an integer type. Integer besties only, iykyk.
π Parameters π
begin,endβ the initial seed sequence represented as a pair of input iterators whosestd::iterator_traits<>::value_typeis an integer type. That's the range vibe.ilβ astd::initializer_listof objects of integer type, providing the initial seed sequence. The list is the moment.
π¦ Type requirements π¦
InputItmust meet the requirements ofLegacyInputIterator. That's the vibe check it has to pass.
π Exceptions π
3,4)β throwsstd::bad_allocon allocation failure. Allocation said nope? You getstd::bad_alloc.
π Example π
// Run this code
#include <iterator>
#include <random>
#include <sstream>
int main()
{
std::seed_seq s1; // default-constructible
std::seed_seq s2{1, 2, 3}; // can use list-initialization
std::seed_seq s3 = {-1, 0, 1}; // another form of list-
initialization
int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::seed_seq s4(a, a + 10); // can use iterators
std::istringstream buf("1 2 3 4 5");
std::istream_iterator<int> beg(buf), end;
std::seed_seq s5(beg, end); // even stream input iterators
}
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. Yes, the standard got a little glow-up after the fact.
- DR:
LWG 3422β Applied to:C++11- Behavior as published: the default constructor never fails but might be not
noexcept; the initializer list constructor disabled list-initialization from iterator pairs - Correct behavior: made
noexcept; constrained
- Behavior as published: the default constructor never fails but might be not
mwah π this page is from the C++ Standard Libary manual, source http://cppreference.com, dated 2024.06.10. That's the whole footer folded into a cute lil' sign-off, bestie. slay π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms