From 051593845dfa97a9787cdf9297e7f47cfeb6cde5 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 10 Oct 2016 05:19:59 +0000 Subject: Workaround missing C++14 constexpr semantics in filesystem git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283714 91177308-0d34-0410-b5e6-96231b3b80d8 --- src/experimental/filesystem/operations.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/experimental') diff --git a/src/experimental/filesystem/operations.cpp b/src/experimental/filesystem/operations.cpp index 795940076..0420e12e3 100644 --- a/src/experimental/filesystem/operations.cpp +++ b/src/experimental/filesystem/operations.cpp @@ -536,7 +536,8 @@ constexpr auto min_time_t = numeric_limits::min(); #pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" #endif -constexpr bool is_representable(TimeSpec const& tm) { +_LIBCPP_CONSTEXPR_AFTER_CXX11 +bool is_representable(TimeSpec const& tm) { if (tm.tv_sec >= 0) { return (tm.tv_sec < max_seconds) || (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec); @@ -546,7 +547,7 @@ constexpr bool is_representable(TimeSpec const& tm) { return (tm.tv_sec >= min_seconds); } } - +#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR #if defined(__LP64__) static_assert(is_representable({max_seconds, max_nsec}), ""); static_assert(!is_representable({max_seconds + 1, 0}), ""); @@ -562,8 +563,10 @@ static_assert(is_representable({max_time_t, 999999999}), ""); static_assert(is_representable({max_time_t, 1000000000}), ""); static_assert(is_representable({min_time_t, 0}), ""); #endif +#endif -constexpr bool is_representable(file_time_type const& tm) { +_LIBCPP_CONSTEXPR_AFTER_CXX11 +bool is_representable(file_time_type const& tm) { auto secs = duration_cast(tm.time_since_epoch()); auto nsecs = duration_cast(tm.time_since_epoch() - secs); if (nsecs.count() < 0) { @@ -575,6 +578,7 @@ constexpr bool is_representable(file_time_type const& tm) { return secs.count() <= TLim::max(); return secs.count() >= TLim::min(); } +#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR #if defined(__LP64__) static_assert(is_representable(file_time_type::max()), ""); static_assert(is_representable(file_time_type::min()), ""); @@ -584,9 +588,10 @@ static_assert(!is_representable(file_time_type::min()), ""); static_assert(is_representable(file_time_type(seconds(max_time_t))), ""); static_assert(is_representable(file_time_type(seconds(min_time_t))), ""); #endif +#endif -template struct Dummy; -constexpr file_time_type convert_timespec(TimeSpec const& tm) { +_LIBCPP_CONSTEXPR_AFTER_CXX11 +file_time_type convert_timespec(TimeSpec const& tm) { auto adj_msec = duration_cast(nanoseconds(tm.tv_nsec)); if (tm.tv_sec >= 0) { auto Dur = seconds(tm.tv_sec) + microseconds(adj_msec); @@ -599,6 +604,7 @@ constexpr file_time_type convert_timespec(TimeSpec const& tm) { return file_time_type(Dur); } } +#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR #if defined(__LP64__) static_assert(convert_timespec({max_seconds, max_nsec}) == file_time_type::max(), ""); static_assert(convert_timespec({max_seconds, max_nsec - 1}) < file_time_type::max(), ""); @@ -609,6 +615,7 @@ static_assert(convert_timespec({min_seconds , 0}) > file_time_type::min(), ""); #else // FIXME add tests for 32 bit builds #endif +#endif #if !defined(__LP64__) && defined(__clang__) #pragma clang diagnostic pop -- cgit v1.2.3