[libcxx] r227860 - [libcxx] Add <experimental/chrono>

Eric Fiselier eric at efcs.ca
Mon Feb 2 13:05:48 PST 2015


Author: ericwf
Date: Mon Feb  2 15:05:47 2015
New Revision: 227860

URL: http://llvm.org/viewvc/llvm-project?rev=227860&view=rev
Log:
[libcxx] Add <experimental/chrono>

Summary:
This patch adds <experimental/chrono> which only contains a single variable template.

See: https://rawgit.com/cplusplus/fundamentals-ts/v1/fundamentals-ts.html#time

Reviewers: jroelofs, danalbert, K-ballo, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7352

Added:
    libcxx/trunk/include/experimental/chrono
    libcxx/trunk/test/libcxx/experimental/
    libcxx/trunk/test/libcxx/experimental/utilities/
    libcxx/trunk/test/libcxx/experimental/utilities/time/
    libcxx/trunk/test/libcxx/experimental/utilities/time/header.chrono.synop/
    libcxx/trunk/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
    libcxx/trunk/test/libcxx/experimental/utilities/time/version.pass.cpp
    libcxx/trunk/test/std/experimental/utilities/time/
    libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/
    libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
    libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp
Modified:
    libcxx/trunk/include/experimental/__config

Modified: libcxx/trunk/include/experimental/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=227860&r1=227859&r2=227860&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Feb  2 15:05:47 2015
@@ -21,4 +21,8 @@
 #define _LIBCPP_END_NAMESPACE_LFTS  } } }
 #define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
 
+#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD        \
+  namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
+#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
+
 #endif

Added: libcxx/trunk/include/experimental/chrono
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/chrono?rev=227860&view=auto
==============================================================================
--- libcxx/trunk/include/experimental/chrono (added)
+++ libcxx/trunk/include/experimental/chrono Mon Feb  2 15:05:47 2015
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//===------------------------------ chrono ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
+#define _LIBCPP_EXPERIMENTAL_CHRONO
+
+/**
+    experimental/chrono synopsis
+
+// C++1y
+
+#include <chrono>
+
+namespace std {
+namespace chrono {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+  // See C++14 20.12.4, customization traits
+  template <class Rep> constexpr bool treat_as_floating_point_v
+    = treat_as_floating_point<Rep>::value;
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace chrono
+} // namespace std
+
+ */
+
+#include <experimental/__config>
+#include <chrono>
+
+#if _LIBCPP_STD_VER > 11
+
+_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS
+
+#if __has_feature(cxx_variable_templates)
+
+template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
+    = treat_as_floating_point<_Rep>::value;
+
+#endif /* __has_feature(cxx_variable_templates) */
+
+_LIBCPP_END_NAMESPACE_CHRONO_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */
\ No newline at end of file

Added: libcxx/trunk/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp?rev=227860&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp Mon Feb  2 15:05:47 2015
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/chrono>
+
+#include <experimental/chrono>
+
+#if _LIBCPP_STD_VER > 11
+# ifndef _LIBCPP_CHRONO
+#   error "<experimental/chrono> must include <chrono>"
+# endif
+#endif
+
+int main()
+{
+}

Added: libcxx/trunk/test/libcxx/experimental/utilities/time/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/utilities/time/version.pass.cpp?rev=227860&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/experimental/utilities/time/version.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/experimental/utilities/time/version.pass.cpp Mon Feb  2 15:05:47 2015
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/chrono>
+
+#include <experimental/chrono>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}

Added: libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp?rev=227860&view=auto
==============================================================================
--- libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp (added)
+++ libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp Mon Feb  2 15:05:47 2015
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/chrono>
+
+#include <experimental/chrono>
+
+int main()
+{
+  // Check that <chrono> has been included.
+  std::chrono::seconds s;
+  ((void)s);
+}

Added: libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp?rev=227860&view=auto
==============================================================================
--- libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp (added)
+++ libcxx/trunk/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp Mon Feb  2 15:05:47 2015
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// <experimental/chrono>
+
+// template <class Rep> constexpr bool treat_as_floating_point_v;
+
+#include <experimental/chrono>
+#include <type_traits>
+
+namespace ex = std::chrono::experimental;
+namespace cr = std::chrono;
+
+template <class T, bool Expect>
+void test()
+{
+  static_assert(
+    ex::treat_as_floating_point_v<T> == Expect, ""
+  );
+  static_assert(
+    ex::treat_as_floating_point_v<T> == cr::treat_as_floating_point<T>::value, ""
+  );
+}
+
+int main()
+{
+  {
+    static_assert(
+      std::is_same<
+        decltype(ex::treat_as_floating_point_v<float>), const bool
+      >::value, ""
+    );
+  }
+  test<int, false>();
+  test<unsigned, false>();
+  test<char, false>();
+  test<bool, false>();
+  test<float, true>();
+  test<double, true>();
+  test<long double, true>();
+}





More information about the cfe-commits mailing list