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:
17
test/utilities/time/clock.h
Normal file
17
test/utilities/time/clock.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef CLOCK_H
|
||||
#define CLOCK_H
|
||||
|
||||
#include <chrono>
|
||||
|
||||
class Clock
|
||||
{
|
||||
typedef std::chrono::nanoseconds duration;
|
||||
typedef duration::rep rep;
|
||||
typedef duration::period period;
|
||||
typedef std::chrono::time_point<Clock, duration> time_point;
|
||||
static const bool is_monotonic = false;
|
||||
|
||||
static time_point now();
|
||||
};
|
||||
|
||||
#endif
|
1
test/utilities/time/hours.pass.cpp
Normal file
1
test/utilities/time/hours.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/microseconds.pass.cpp
Normal file
1
test/utilities/time/microseconds.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/milliseconds.pass.cpp
Normal file
1
test/utilities/time/milliseconds.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/minutes.pass.cpp
Normal file
1
test/utilities/time/minutes.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/nanoseconds.pass.cpp
Normal file
1
test/utilities/time/nanoseconds.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
18
test/utilities/time/rep.h
Normal file
18
test/utilities/time/rep.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef REP_H
|
||||
#define REP_H
|
||||
|
||||
class Rep
|
||||
{
|
||||
int data_;
|
||||
public:
|
||||
Rep() : data_(-1) {}
|
||||
explicit Rep(int i) : data_(i) {}
|
||||
|
||||
bool operator==(int i) const {return data_ == i;}
|
||||
bool operator==(const Rep& r) const {return data_ == r.data_;}
|
||||
|
||||
Rep& operator*=(Rep x) {data_ *= x.data_; return *this;}
|
||||
Rep& operator/=(Rep x) {data_ /= x.data_; return *this;}
|
||||
};
|
||||
|
||||
#endif
|
1
test/utilities/time/seconds.pass.cpp
Normal file
1
test/utilities/time/seconds.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/time.clock/nothing_to_do.pass.cpp
Normal file
1
test/utilities/time/time.clock/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/time.duration/default_ratio.pass.cpp
Normal file
1
test/utilities/time/time.duration/default_ratio.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/time.duration/duration.fail.cpp
Normal file
1
test/utilities/time/time.duration/duration.fail.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/time.duration/positive_num.fail.cpp
Normal file
1
test/utilities/time/time.duration/positive_num.fail.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/time/time.duration/ratio.fail.cpp
Normal file
1
test/utilities/time/time.duration/ratio.fail.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// template <class Rep1, class Period, class Rep2>
|
||||
// duration<typename common_type<Rep1, Rep2>::type, Period>
|
||||
// operator%(const duration<Rep1, Period>& d, const Rep2& s)
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::chrono::nanoseconds ns(15);
|
||||
ns = ns % 6;
|
||||
assert(ns.count() == 3);
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// template <class Rep1, class Period, class Rep2>
|
||||
// duration<typename common_type<Rep1, Rep2>::type, Period>
|
||||
// operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
||||
|
||||
// template <class Rep1, class Period, class Rep2>
|
||||
// duration<typename common_type<Rep1, Rep2>::type, Period>
|
||||
// operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::chrono::nanoseconds ns(3);
|
||||
ns = ns * 5;
|
||||
assert(ns.count() == 15);
|
||||
ns = 6 * ns;
|
||||
assert(ns.count() == 90);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// template <class Rep1, class Period, class Rep2>
|
||||
// duration<typename common_type<Rep1, Rep2>::type, Period>
|
||||
// operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
||||
|
||||
// template <class Rep1, class Period, class Rep2>
|
||||
// duration<typename common_type<Rep1, Rep2>::type, Period>
|
||||
// operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::chrono::duration<Rep> d;
|
||||
d = d * 5;
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// template <class Rep1, class Period, class Rep2>
|
||||
// duration<typename common_type<Rep1, Rep2>::type, Period>
|
||||
// operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
||||
|
||||
// template <class Rep1, class Period, class Rep2>
|
||||
// duration<typename common_type<Rep1, Rep2>::type, Period>
|
||||
// operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::chrono::duration<Rep> d;
|
||||
d = 5 * d;
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// static constexpr duration max();
|
||||
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
template <class D>
|
||||
void test()
|
||||
{
|
||||
typedef typename D::rep Rep;
|
||||
Rep max_rep = std::chrono::duration_values<Rep>::max();
|
||||
assert(D::max().count() == max_rep);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::chrono::duration<int> >();
|
||||
test<std::chrono::duration<Rep> >();
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// static constexpr duration min();
|
||||
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
template <class D>
|
||||
void test()
|
||||
{
|
||||
typedef typename D::rep Rep;
|
||||
Rep min_rep = std::chrono::duration_values<Rep>::min();
|
||||
assert(D::min().count() == min_rep);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::chrono::duration<int> >();
|
||||
test<std::chrono::duration<Rep> >();
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// static constexpr duration zero();
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
template <class D>
|
||||
void test()
|
||||
{
|
||||
typedef typename D::rep Rep;
|
||||
Rep zero_rep = std::chrono::duration_values<Rep>::zero();
|
||||
assert(D::zero().count() == zero_rep);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::chrono::duration<int> >();
|
||||
test<std::chrono::duration<Rep> >();
|
||||
}
|
27
test/utilities/time/time.duration/types.pass.cpp
Normal file
27
test/utilities/time/time.duration/types.pass.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration
|
||||
|
||||
// Test nested types
|
||||
|
||||
// typedef Rep rep;
|
||||
// typedef Period period;
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::duration<long, std::ratio<3, 2> > D;
|
||||
static_assert((std::is_same<D::rep, long>::value), "");
|
||||
static_assert((std::is_same<D::period, std::ratio<3, 2> >::value), "");
|
||||
}
|
26
test/utilities/time/time.point/default_duration.pass.cpp
Normal file
26
test/utilities/time/time.point/default_duration.pass.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// Test default template arg:
|
||||
|
||||
// template <class Clock, class Duration = typename Clock::duration>
|
||||
// class time_point;
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_same<std::chrono::system_clock::duration,
|
||||
std::chrono::time_point<std::chrono::system_clock>::duration>::value), "");
|
||||
}
|
22
test/utilities/time/time.point/duration.fail.cpp
Normal file
22
test/utilities/time/time.point/duration.fail.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// Duration shall be an instance of duration.
|
||||
|
||||
#include <chrono>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::time_point<std::chrono::system_clock, int> T;
|
||||
T t;
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// time_point& operator+=(const duration& d);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration;
|
||||
std::chrono::time_point<Clock, Duration> t(Duration(3));
|
||||
t += Duration(2);
|
||||
assert(t.time_since_epoch() == Duration(5));
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// time_point& operator-=(const duration& d);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration;
|
||||
std::chrono::time_point<Clock, Duration> t(Duration(3));
|
||||
t -= Duration(2);
|
||||
assert(t.time_since_epoch() == Duration(1));
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class ToDuration, class Clock, class Duration>
|
||||
// time_point<Clock, ToDuration>
|
||||
// time_point_cast(const time_point<Clock, Duration>& t);
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template <class FromDuration, class ToDuration>
|
||||
void
|
||||
test(const FromDuration& df, const ToDuration& d)
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
|
||||
typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
|
||||
FromTimePoint f(df);
|
||||
ToTimePoint t(d);
|
||||
typedef decltype(std::chrono::time_point_cast<ToDuration>(f)) R;
|
||||
static_assert((std::is_same<R, ToTimePoint>::value), "");
|
||||
assert(std::chrono::time_point_cast<ToDuration>(f) == t);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::chrono::milliseconds(7265000), std::chrono::hours(2));
|
||||
test(std::chrono::milliseconds(7265000), std::chrono::minutes(121));
|
||||
test(std::chrono::milliseconds(7265000), std::chrono::seconds(7265));
|
||||
test(std::chrono::milliseconds(7265000), std::chrono::milliseconds(7265000));
|
||||
test(std::chrono::milliseconds(7265000), std::chrono::microseconds(7265000000LL));
|
||||
test(std::chrono::milliseconds(7265000), std::chrono::nanoseconds(7265000000000LL));
|
||||
test(std::chrono::milliseconds(7265000),
|
||||
std::chrono::duration<double, std::ratio<3600> >(7265./3600));
|
||||
test(std::chrono::duration<int, std::ratio<2, 3> >(9),
|
||||
std::chrono::duration<int, std::ratio<3, 5> >(10));
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class ToDuration, class Clock, class Duration>
|
||||
// time_point<Clock, ToDuration>
|
||||
// time_point_cast(const time_point<Clock, Duration>& t);
|
||||
|
||||
// ToDuration shall be an instantiation of duration.
|
||||
|
||||
#include <chrono>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::time_point<Clock, std::chrono::milliseconds> FromTimePoint;
|
||||
typedef std::chrono::time_point<Clock, std::chrono::minutes> ToTimePoint;
|
||||
std::chrono::time_point_cast<ToTimePoint>(FromTimePoint(std::chrono::milliseconds(3)));
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// time_points with different clocks should not compare
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "../../clock.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock1;
|
||||
typedef Clock Clock2;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
typedef std::chrono::time_point<Clock1, Duration1> T1;
|
||||
typedef std::chrono::time_point<Clock2, Duration2> T2;
|
||||
|
||||
T1 t1(Duration1(3));
|
||||
T2 t2(Duration2(3000));
|
||||
t1 == t2;
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
typedef std::chrono::time_point<Clock, Duration1> T1;
|
||||
typedef std::chrono::time_point<Clock, Duration2> T2;
|
||||
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T1 t2(Duration1(3));
|
||||
assert( (t1 == t2));
|
||||
assert(!(t1 != t2));
|
||||
}
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T1 t2(Duration1(4));
|
||||
assert(!(t1 == t2));
|
||||
assert( (t1 != t2));
|
||||
}
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T2 t2(Duration2(3000));
|
||||
assert( (t1 == t2));
|
||||
assert(!(t1 != t2));
|
||||
}
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T2 t2(Duration2(3001));
|
||||
assert(!(t1 == t2));
|
||||
assert( (t1 != t2));
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// time_points with different clocks should not compare
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "../../clock.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock1;
|
||||
typedef Clock Clock2;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
typedef std::chrono::time_point<Clock1, Duration1> T1;
|
||||
typedef std::chrono::time_point<Clock2, Duration2> T2;
|
||||
|
||||
T1 t1(Duration1(3));
|
||||
T2 t2(Duration2(3000));
|
||||
t1 < t2;
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// bool
|
||||
// operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
typedef std::chrono::time_point<Clock, Duration1> T1;
|
||||
typedef std::chrono::time_point<Clock, Duration2> T2;
|
||||
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T1 t2(Duration1(3));
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 <= t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T1 t2(Duration1(4));
|
||||
assert( (t1 < t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T2 t2(Duration2(3000));
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 <= t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
T1 t1(Duration1(3));
|
||||
T2 t2(Duration2(3001));
|
||||
assert( (t1 < t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Duration2>
|
||||
// time_point(const time_point<clock, Duration2>& t);
|
||||
|
||||
// Duration2 shall be implicitly convertible to duration.
|
||||
|
||||
#include <chrono>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
|
||||
std::chrono::time_point<Clock, Duration1> t1 = t2;
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Duration2>
|
||||
// time_point(const time_point<clock, Duration2>& t);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::microseconds Duration1;
|
||||
typedef std::chrono::milliseconds Duration2;
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
|
||||
std::chrono::time_point<Clock, Duration1> t1 = t2;
|
||||
assert(t1.time_since_epoch() == Duration1(3000));
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// time_point();
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::duration<Rep, std::milli> Duration;
|
||||
std::chrono::time_point<Clock, Duration> t;
|
||||
assert(t.time_since_epoch() == Duration::zero());
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// explicit time_point(const duration& d);
|
||||
|
||||
// test for explicit
|
||||
|
||||
#include <chrono>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration;
|
||||
std::chrono::time_point<Clock, Duration> t = Duration(3);
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// explicit time_point(const duration& d);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration;
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration> t(Duration(3));
|
||||
assert(t.time_since_epoch() == Duration(3));
|
||||
}
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
|
||||
assert(t.time_since_epoch() == Duration(3000));
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Clock, class Duration1, class Rep2, class Period2>
|
||||
// time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
|
||||
// operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
||||
|
||||
// template <class Rep1, class Period1, class Clock, class Duration2>
|
||||
// time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
|
||||
// operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
|
||||
assert(t2.time_since_epoch() == Duration2(3005));
|
||||
t2 = Duration2(6) + t1;
|
||||
assert(t2.time_since_epoch() == Duration2(3006));
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Clock, class Duration1, class Rep2, class Period2>
|
||||
// time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
|
||||
// operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
|
||||
assert(t2.time_since_epoch() == Duration2(2995));
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// typename common_type<Duration1, Duration2>::type
|
||||
// operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
|
||||
assert((t1 - t2) == Duration2(2995));
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// static constexpr time_point max();
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration;
|
||||
typedef std::chrono::time_point<Clock, Duration> TP;
|
||||
assert(TP::max() == TP(Duration::max()));
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// time_point
|
||||
|
||||
// static constexpr time_point min();
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration;
|
||||
typedef std::chrono::time_point<Clock, Duration> TP;
|
||||
assert(TP::min() == TP(Duration::min()));
|
||||
}
|
12
test/utilities/time/time.traits/nothing_to_do.pass.cpp
Normal file
12
test/utilities/time/time.traits/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration_values::max
|
||||
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::chrono::duration_values<int>::max() ==
|
||||
std::numeric_limits<int>::max());
|
||||
assert(std::chrono::duration_values<double>::max() ==
|
||||
std::numeric_limits<double>::max());
|
||||
assert(std::chrono::duration_values<Rep>::max() ==
|
||||
std::numeric_limits<Rep>::max());
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration_values::min
|
||||
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::chrono::duration_values<int>::min() ==
|
||||
std::numeric_limits<int>::lowest());
|
||||
assert(std::chrono::duration_values<double>::min() ==
|
||||
std::numeric_limits<double>::lowest());
|
||||
assert(std::chrono::duration_values<Rep>::min() ==
|
||||
std::numeric_limits<Rep>::lowest());
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// duration_values::zero
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../rep.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::chrono::duration_values<int>::zero() == 0);
|
||||
assert(std::chrono::duration_values<Rep>::zero() == 0);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// treat_as_floating_point
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
{
|
||||
static_assert((std::is_base_of<std::is_floating_point<T>,
|
||||
std::chrono::treat_as_floating_point<T> >::value), "");
|
||||
}
|
||||
|
||||
struct A {};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int>();
|
||||
test<unsigned>();
|
||||
test<char>();
|
||||
test<bool>();
|
||||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
test<A>();
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// template <class Rep1, class Period1, class Rep2, class Period2>
|
||||
// struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
|
||||
// {
|
||||
// typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type;
|
||||
// };
|
||||
|
||||
#include <chrono>
|
||||
|
||||
template <class D1, class D2, class De>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef typename std::common_type<D1, D2>::type Dc;
|
||||
static_assert((std::is_same<Dc, De>::value), "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::chrono::duration<int, std::ratio<1, 100> >,
|
||||
std::chrono::duration<long, std::ratio<1, 1000> >,
|
||||
std::chrono::duration<long, std::ratio<1, 1000> > >();
|
||||
test<std::chrono::duration<long, std::ratio<1, 100> >,
|
||||
std::chrono::duration<int, std::ratio<1, 1000> >,
|
||||
std::chrono::duration<long, std::ratio<1, 1000> > >();
|
||||
test<std::chrono::duration<char, std::ratio<1, 30> >,
|
||||
std::chrono::duration<short, std::ratio<1, 1000> >,
|
||||
std::chrono::duration<int, std::ratio<1, 3000> > >();
|
||||
test<std::chrono::duration<double, std::ratio<21, 1> >,
|
||||
std::chrono::duration<short, std::ratio<15, 1> >,
|
||||
std::chrono::duration<double, std::ratio<3, 1> > >();
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
// template <class Clock, class Duration1, class Duration2>
|
||||
// struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>
|
||||
// {
|
||||
// typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type;
|
||||
// };
|
||||
|
||||
#include <chrono>
|
||||
|
||||
template <class D1, class D2, class De>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::chrono::system_clock C;
|
||||
typedef std::chrono::time_point<C, D1> T1;
|
||||
typedef std::chrono::time_point<C, D2> T2;
|
||||
typedef std::chrono::time_point<C, De> Te;
|
||||
typedef typename std::common_type<T1, T2>::type Tc;
|
||||
static_assert((std::is_same<Tc, Te>::value), "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::chrono::duration<int, std::ratio<1, 100> >,
|
||||
std::chrono::duration<long, std::ratio<1, 1000> >,
|
||||
std::chrono::duration<long, std::ratio<1, 1000> > >();
|
||||
test<std::chrono::duration<long, std::ratio<1, 100> >,
|
||||
std::chrono::duration<int, std::ratio<1, 1000> >,
|
||||
std::chrono::duration<long, std::ratio<1, 1000> > >();
|
||||
test<std::chrono::duration<char, std::ratio<1, 30> >,
|
||||
std::chrono::duration<short, std::ratio<1, 1000> >,
|
||||
std::chrono::duration<int, std::ratio<1, 3000> > >();
|
||||
test<std::chrono::duration<double, std::ratio<21, 1> >,
|
||||
std::chrono::duration<short, std::ratio<15, 1> >,
|
||||
std::chrono::duration<double, std::ratio<3, 1> > >();
|
||||
}
|
20
test/utilities/time/version.pass.cpp
Normal file
20
test/utilities/time/version.pass.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user