~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to system/include/libcxx/chrono

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
    duration d_;  // exposition only
112
112
 
113
113
public:
114
 
    time_point();  // has value "epoch"
115
 
    explicit time_point(const duration& d);  // same as time_point() + d
 
114
    time_point();  // has value "epoch" // constexpr in C++14
 
115
    explicit time_point(const duration& d);  // same as time_point() + d // constexpr in C++14
116
116
 
117
117
    // conversions
118
118
    template <class Duration2>
119
 
       time_point(const time_point<clock, Duration2>& t);
 
119
       time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
120
120
 
121
121
    // observer
122
122
 
123
 
    duration time_since_epoch() const;
 
123
    duration time_since_epoch() const; // constexpr in C++14
124
124
 
125
125
    // arithmetic
126
126
 
194
194
template <class ToDuration, class Rep, class Period>
195
195
  ToDuration duration_cast(const duration<Rep, Period>& d);
196
196
 
197
 
// time_point arithmetic
 
197
// time_point arithmetic (all constexpr in C++14)
198
198
template <class Clock, class Duration1, class Rep2, class Period2>
199
199
  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
200
200
  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
208
208
  typename common_type<Duration1, Duration2>::type
209
209
  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
210
210
 
211
 
// time_point comparisons
 
211
// time_point comparisons (all constexpr in C++14)
212
212
template <class Clock, class Duration1, class Duration2>
213
213
   bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
214
214
template <class Clock, class Duration1, class Duration2>
222
222
template <class Clock, class Duration1, class Duration2>
223
223
   bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
224
224
 
225
 
// time_point_cast
 
225
// time_point_cast (constexpr in C++14)
226
226
 
227
227
template <class ToDuration, class Clock, class Duration>
228
228
  time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
236
236
    typedef duration::rep                    rep;
237
237
    typedef duration::period                 period;
238
238
    typedef chrono::time_point<system_clock> time_point;
239
 
    static const bool is_steady =            false;
 
239
    static const bool is_steady =            false; // constexpr in C++14
240
240
 
241
241
    static time_point now() noexcept;
242
242
    static time_t     to_time_t  (const time_point& __t) noexcept;
250
250
    typedef duration::rep                                 rep;
251
251
    typedef duration::period                              period;
252
252
    typedef chrono::time_point<steady_clock, duration>    time_point;
253
 
    static const bool is_steady =                         true;
 
253
    static const bool is_steady =                         true; // constexpr in C++14
254
254
 
255
255
    static time_point now() noexcept;
256
256
};
259
259
 
260
260
}  // chrono
261
261
 
 
262
constexpr chrono::hours                                 operator "" h(unsigned long long); // C++14
 
263
constexpr chrono::duration<unspecified , ratio<3600,1>> operator "" h(long double); // C++14
 
264
constexpr chrono::minutes                               operator "" min(unsigned long long); // C++14
 
265
constexpr chrono::duration<unspecified , ratio<60,1>>   operator "" min(long double); // C++14
 
266
constexpr chrono::seconds                               operator "" s(unsigned long long); // C++14
 
267
constexpr chrono::duration<unspecified >                operator "" s(long double); // C++14
 
268
constexpr chrono::milliseconds                          operator "" ms(unsigned long long); // C++14
 
269
constexpr chrono::duration<unspecified , milli>         operator "" ms(long double); // C++14
 
270
constexpr chrono::microseconds                          operator "" us(unsigned long long); // C++14
 
271
constexpr chrono::duration<unspecified , micro>         operator "" us(long double); // C++14
 
272
constexpr chrono::nanoseconds                           operator "" ns(unsigned long long); // C++14
 
273
constexpr chrono::duration<unspecified , nano>          operator "" ns(long double); // C++14
 
274
 
262
275
}  // std
263
276
*/
264
277
 
403
416
    rep __rep_;
404
417
public:
405
418
 
406
 
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration() {} // = default;
 
419
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
 
420
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
421
        duration() = default;
 
422
#else
 
423
        duration() {}
 
424
#endif
 
425
 
407
426
    template <class _Rep2>
408
427
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
409
428
        explicit duration(const _Rep2& __r,
468
487
struct __duration_eq
469
488
{
470
489
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
471
 
    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs)
 
490
    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
472
491
        {
473
492
            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
474
493
            return _Ct(__lhs).count() == _Ct(__rhs).count();
479
498
struct __duration_eq<_LhsDuration, _LhsDuration>
480
499
{
481
500
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
482
 
    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs)
 
501
    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
483
502
        {return __lhs.count() == __rhs.count();}
484
503
};
485
504
 
509
528
struct __duration_lt
510
529
{
511
530
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
512
 
    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs)
 
531
    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
513
532
        {
514
533
            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
515
534
            return _Ct(__lhs).count() < _Ct(__rhs).count();
520
539
struct __duration_lt<_LhsDuration, _LhsDuration>
521
540
{
522
541
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
523
 
    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs)
 
542
    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
524
543
        {return __lhs.count() < __rhs.count();}
525
544
};
526
545
 
709
728
    duration __d_;
710
729
 
711
730
public:
712
 
    _LIBCPP_INLINE_VISIBILITY time_point() : __d_(duration::zero()) {}
713
 
    _LIBCPP_INLINE_VISIBILITY explicit time_point(const duration& __d) : __d_(__d) {}
 
731
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}
 
732
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}
714
733
 
715
734
    // conversions
716
735
    template <class _Duration2>
717
 
    _LIBCPP_INLINE_VISIBILITY
 
736
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
718
737
    time_point(const time_point<clock, _Duration2>& t,
719
738
        typename enable_if
720
739
        <
724
743
 
725
744
    // observer
726
745
 
727
 
    _LIBCPP_INLINE_VISIBILITY duration time_since_epoch() const {return __d_;}
 
746
    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
728
747
 
729
748
    // arithmetic
730
749
 
731
 
        _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
732
 
        _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
 
750
    _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
 
751
    _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
733
752
 
734
753
    // special values
735
754
 
749
768
namespace chrono {
750
769
 
751
770
template <class _ToDuration, class _Clock, class _Duration>
752
 
inline _LIBCPP_INLINE_VISIBILITY
 
771
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
753
772
time_point<_Clock, _ToDuration>
754
773
time_point_cast(const time_point<_Clock, _Duration>& __t)
755
774
{
759
778
// time_point ==
760
779
 
761
780
template <class _Clock, class _Duration1, class _Duration2>
762
 
inline _LIBCPP_INLINE_VISIBILITY
 
781
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
763
782
bool
764
783
operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
765
784
{
769
788
// time_point !=
770
789
 
771
790
template <class _Clock, class _Duration1, class _Duration2>
772
 
inline _LIBCPP_INLINE_VISIBILITY
 
791
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
773
792
bool
774
793
operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
775
794
{
779
798
// time_point <
780
799
 
781
800
template <class _Clock, class _Duration1, class _Duration2>
782
 
inline _LIBCPP_INLINE_VISIBILITY
 
801
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
783
802
bool
784
803
operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
785
804
{
789
808
// time_point >
790
809
 
791
810
template <class _Clock, class _Duration1, class _Duration2>
792
 
inline _LIBCPP_INLINE_VISIBILITY
 
811
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
793
812
bool
794
813
operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
795
814
{
799
818
// time_point <=
800
819
 
801
820
template <class _Clock, class _Duration1, class _Duration2>
802
 
inline _LIBCPP_INLINE_VISIBILITY
 
821
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
803
822
bool
804
823
operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
805
824
{
809
828
// time_point >=
810
829
 
811
830
template <class _Clock, class _Duration1, class _Duration2>
812
 
inline _LIBCPP_INLINE_VISIBILITY
 
831
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
813
832
bool
814
833
operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
815
834
{
819
838
// time_point operator+(time_point x, duration y);
820
839
 
821
840
template <class _Clock, class _Duration1, class _Rep2, class _Period2>
822
 
inline _LIBCPP_INLINE_VISIBILITY
 
841
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
823
842
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
824
843
operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
825
844
{
826
845
    typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
827
 
    _Tr __r(__lhs.time_since_epoch());
828
 
    __r += __rhs;
829
 
    return __r;
 
846
    return _Tr (__lhs.time_since_epoch() + __rhs);
830
847
}
831
848
 
832
849
// time_point operator+(duration x, time_point y);
833
850
 
834
851
template <class _Rep1, class _Period1, class _Clock, class _Duration2>
835
 
inline _LIBCPP_INLINE_VISIBILITY
 
852
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
836
853
time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
837
854
operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
838
855
{
842
859
// time_point operator-(time_point x, duration y);
843
860
 
844
861
template <class _Clock, class _Duration1, class _Rep2, class _Period2>
845
 
inline _LIBCPP_INLINE_VISIBILITY
 
862
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
846
863
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
847
864
operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
848
865
{
852
869
// duration operator-(time_point x, time_point y);
853
870
 
854
871
template <class _Clock, class _Duration1, class _Duration2>
855
 
inline _LIBCPP_INLINE_VISIBILITY
 
872
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
856
873
typename common_type<_Duration1, _Duration2>::type
857
874
operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
858
875
{
870
887
    typedef duration::rep                    rep;
871
888
    typedef duration::period                 period;
872
889
    typedef chrono::time_point<system_clock> time_point;
873
 
    static const bool is_steady =            false;
 
890
    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
874
891
 
875
892
    static time_point now() _NOEXCEPT;
876
893
    static time_t     to_time_t  (const time_point& __t) _NOEXCEPT;
884
901
    typedef duration::rep                                 rep;
885
902
    typedef duration::period                              period;
886
903
    typedef chrono::time_point<steady_clock, duration>    time_point;
887
 
    static const bool is_steady =                         true;
 
904
    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true;
888
905
 
889
906
    static time_point now() _NOEXCEPT;
890
907
};
893
910
 
894
911
} // chrono
895
912
 
 
913
#if _LIBCPP_STD_VER > 11 
 
914
// Literal suffixes for chrono types
 
915
// inline // Deviation from N3690.
 
916
//    We believe the inline to be a defect and have submitted an LWG issue.
 
917
//    An LWG issue number has not yet been assigned.
 
918
namespace literals
 
919
 
920
  inline namespace chrono_literals
 
921
  {
 
922
 
 
923
    constexpr chrono::hours operator"" h(unsigned long long __h)
 
924
    {
 
925
        return chrono::hours(static_cast<chrono::hours::rep>(__h));
 
926
    }
 
927
 
 
928
    constexpr chrono::duration<long double, ratio<3600,1>> operator"" h(long double __h)
 
929
    {
 
930
        return chrono::duration<long double, ratio<3600,1>>(__h);
 
931
    }
 
932
 
 
933
 
 
934
    constexpr chrono::minutes operator"" min(unsigned long long __m)
 
935
    {
 
936
        return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
 
937
    }
 
938
 
 
939
    constexpr chrono::duration<long double, ratio<60,1>> operator"" min(long double __m)
 
940
    {
 
941
        return chrono::duration<long double, ratio<60,1>> (__m);
 
942
    }
 
943
 
 
944
 
 
945
    constexpr chrono::seconds operator"" s(unsigned long long __s)
 
946
    {
 
947
        return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
 
948
    }
 
949
 
 
950
    constexpr chrono::duration<long double> operator"" s(long double __s)
 
951
    {
 
952
        return chrono::duration<long double> (__s);
 
953
    }
 
954
 
 
955
 
 
956
    constexpr chrono::milliseconds operator"" ms(unsigned long long __ms)
 
957
    {
 
958
        return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
 
959
    }
 
960
 
 
961
    constexpr chrono::duration<long double, milli> operator"" ms(long double __ms)
 
962
    {
 
963
        return chrono::duration<long double, milli>(__ms);
 
964
    }
 
965
 
 
966
 
 
967
    constexpr chrono::microseconds operator"" us(unsigned long long __us)
 
968
    {
 
969
        return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
 
970
    }
 
971
 
 
972
    constexpr chrono::duration<long double, micro> operator"" us(long double __us)
 
973
    {
 
974
        return chrono::duration<long double, micro> (__us);
 
975
    }
 
976
    
 
977
 
 
978
    constexpr chrono::nanoseconds operator"" ns(unsigned long long __ns)
 
979
    {
 
980
        return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
 
981
    }
 
982
 
 
983
    constexpr chrono::duration<long double, nano> operator"" ns(long double __ns)
 
984
    {
 
985
        return chrono::duration<long double, nano> (__ns);
 
986
    }
 
987
 
 
988
}}
 
989
#endif
 
990
 
896
991
_LIBCPP_END_NAMESPACE_STD
897
992
 
898
993
#endif  // _LIBCPP_CHRONO