libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// discard_block_engine& operator=(const discard_block_engine&);
|
||||
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
typedef std::ranlux24 E;
|
||||
E e1(2);
|
||||
e1();
|
||||
E e2(5);
|
||||
e2 = e1;
|
||||
assert(e1 == e2);
|
||||
assert(e1() == e2());
|
||||
E::result_type k = e1();
|
||||
assert(e1 != e2);
|
||||
assert(e2() == k);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
typedef std::ranlux48 E;
|
||||
E e1(3);
|
||||
e1();
|
||||
E e2(5);
|
||||
e2 = e1;
|
||||
assert(e1 == e2);
|
||||
assert(e1() == e2());
|
||||
E::result_type k = e1();
|
||||
assert(e1 != e2);
|
||||
assert(e2() == k);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
54
test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
Normal file
54
test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// discard_block_engine(const discard_block_engine&);
|
||||
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
typedef std::ranlux24 E;
|
||||
E e1;
|
||||
e1();
|
||||
E e2 = e1;
|
||||
assert(e1 == e2);
|
||||
assert(e1() == e2());
|
||||
E::result_type k = e1();
|
||||
assert(e1 != e2);
|
||||
assert(e2() == k);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
typedef std::ranlux48 E;
|
||||
E e1;
|
||||
e1();
|
||||
E e2 = e1;
|
||||
assert(e1 == e2);
|
||||
assert(e1() == e2());
|
||||
E::result_type k = e1();
|
||||
assert(e1 != e2);
|
||||
assert(e2() == k);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// explicit discard_block_engine(result_type s = default_seed);
|
||||
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
|
||||
"16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
|
||||
"13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
|
||||
"5707268 2355175 0 0";
|
||||
std::ranlux24 e1(0);
|
||||
std::ostringstream os;
|
||||
os << e1;
|
||||
assert(os.str() == a);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
const char* a = "10880375256626 126660097854724 33643165434010 "
|
||||
"78293780235492 179418984296008 96783156950859 238199764491708 "
|
||||
"34339434557790 155299155394531 29014415493780 209265474179052 "
|
||||
"263777435457028 0 0";
|
||||
std::ranlux48 e1(0);
|
||||
std::ostringstream os;
|
||||
os << e1;
|
||||
assert(os.str() == a);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// template<class Sseq> explicit discard_block_engine(Sseq& q);
|
||||
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
|
||||
"3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
|
||||
"14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
|
||||
"889045 0 0";
|
||||
unsigned as[] = {3, 5, 7};
|
||||
std::seed_seq sseq(as, as+3);
|
||||
std::ranlux24 e1(sseq);
|
||||
std::ostringstream os;
|
||||
os << e1;
|
||||
assert(os.str() == a);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
const char* a = "241408498702289 172342669275054 191026374555184 "
|
||||
"61020585639411 231929771458953 142769679250755 198672786411514 "
|
||||
"183712717244841 227473912549724 62843577252444 68782400568421 "
|
||||
"159248704678140 0 0";
|
||||
unsigned as[] = {3, 5, 7};
|
||||
std::seed_seq sseq(as, as+3);
|
||||
std::ranlux48 e1(sseq);
|
||||
std::ostringstream os;
|
||||
os << e1;
|
||||
assert(os.str() == a);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// explicit discard_block_engine();
|
||||
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
std::ranlux24 e1;
|
||||
std::ranlux24 e2(std::ranlux24_base::default_seed);
|
||||
assert(e1 == e2);
|
||||
assert(e1() == 15039276);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
std::ranlux48 e1;
|
||||
std::ranlux48 e2(std::ranlux48_base::default_seed);
|
||||
assert(e1 == e2);
|
||||
assert(e1() == 23459059301164ull);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// void discard(unsigned long long z);
|
||||
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
std::ranlux24 e1;
|
||||
std::ranlux24 e2 = e1;
|
||||
assert(e1 == e2);
|
||||
e1.discard(3);
|
||||
assert(e1 != e2);
|
||||
e2();
|
||||
e2();
|
||||
e2();
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
std::ranlux48 e1;
|
||||
std::ranlux48 e2 = e1;
|
||||
assert(e1 == e2);
|
||||
e1.discard(3);
|
||||
assert(e1 != e2);
|
||||
e2();
|
||||
e2();
|
||||
e2();
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
42
test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
Normal file
42
test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// result_type operator()();
|
||||
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
std::ranlux24 e;
|
||||
assert(e() == 15039276u);
|
||||
assert(e() == 16323925u);
|
||||
assert(e() == 14283486u);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
std::ranlux48 e;
|
||||
assert(e() == 23459059301164ull);
|
||||
assert(e() == 28639057539807ull);
|
||||
assert(e() == 276846226770426ull);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
63
test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
Normal file
63
test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// template <class charT, class traits,
|
||||
// class Engine, size_t p, size_t r>
|
||||
// basic_ostream<charT, traits>&
|
||||
// operator<<(basic_ostream<charT, traits>& os,
|
||||
// const discard_block_engine<Engine, p, r>& x);
|
||||
//
|
||||
// template <class charT, class traits,
|
||||
// class Engine, size_t p, size_t r>
|
||||
// basic_istream<charT, traits>&
|
||||
// operator>>(basic_istream<charT, traits>& is,
|
||||
// discard_block_engine<Engine, p, r>& x);
|
||||
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
typedef std::ranlux24 E;
|
||||
E e1;
|
||||
e1.discard(100);
|
||||
std::ostringstream os;
|
||||
os << e1;
|
||||
std::istringstream is(os.str());
|
||||
E e2;
|
||||
is >> e2;
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
typedef std::ranlux48 E;
|
||||
E e1;
|
||||
e1.discard(100);
|
||||
std::ostringstream os;
|
||||
os << e1;
|
||||
std::istringstream is(os.str());
|
||||
E e2;
|
||||
is >> e2;
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
// {
|
||||
// public:
|
||||
// // types
|
||||
// typedef typename Engine::result_type result_type;
|
||||
|
||||
#include <random>
|
||||
#include <type_traits>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
static_assert((std::is_same<
|
||||
std::ranlux24::result_type,
|
||||
std::uint_fast32_t>::value), "");
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
static_assert((std::is_same<
|
||||
std::ranlux48::result_type,
|
||||
std::uint_fast64_t>::value), "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// void seed(result_type s = default_seed);
|
||||
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
for (int s = 0; s < 20; ++s)
|
||||
{
|
||||
typedef std::ranlux24 E;
|
||||
E e1(s);
|
||||
E e2;
|
||||
e2.seed(s);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
for (int s = 0; s < 20; ++s)
|
||||
{
|
||||
typedef std::ranlux48 E;
|
||||
E e1(s);
|
||||
E e2;
|
||||
e2.seed(s);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
|
||||
// template<class Sseq> void seed(Sseq& q);
|
||||
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
unsigned a[] = {3, 5, 7};
|
||||
std::seed_seq sseq(a, a+3);
|
||||
std::ranlux24 e1;
|
||||
std::ranlux24 e2(sseq);
|
||||
assert(e1 != e2);
|
||||
e1.seed(sseq);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
unsigned a[] = {3, 5, 7};
|
||||
std::seed_seq sseq(a, a+3);
|
||||
std::ranlux48 e1;
|
||||
std::ranlux48 e2(sseq);
|
||||
assert(e1 != e2);
|
||||
e1.seed(sseq);
|
||||
assert(e1 == e2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <random>
|
||||
|
||||
// template<class Engine, size_t p, size_t r>
|
||||
// class discard_block_engine
|
||||
// {
|
||||
// public:
|
||||
// // types
|
||||
// typedef typename Engine::result_type result_type;
|
||||
//
|
||||
// // engine characteristics
|
||||
// static constexpr size_t block_size = p;
|
||||
// static constexpr size_t used_block = r;
|
||||
// static constexpr result_type min() { return Engine::min(); }
|
||||
// static constexpr result_type max() { return Engine::max(); }
|
||||
|
||||
#include <random>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
typedef std::ranlux24 E;
|
||||
static_assert((E::block_size == 223), "");
|
||||
static_assert((E::used_block == 23), "");
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
|
||||
}
|
||||
|
||||
void
|
||||
test2()
|
||||
{
|
||||
typedef std::ranlux48 E;
|
||||
static_assert((E::block_size == 389), "");
|
||||
static_assert((E::used_block == 11), "");
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
}
|
||||
Reference in New Issue
Block a user