Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Enable y and d literals in C++14.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhemstad committed Oct 5, 2020
1 parent dec3dac commit 3f388de
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// UNSUPPORTED: c++98, c++03, c++11
// UNSUPPORTED: clang-5, clang-6
// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9, apple-clang-10

Expand All @@ -16,7 +16,7 @@

#include <cuda/std/chrono>
#include <cuda/std/type_traits>
#include <cassert>
#include <cuda/std/cassert>

#include "test_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// UNSUPPORTED: c++98, c++03, c++11
// UNSUPPORTED: clang-5, clang-6, clang-7
// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
// UNSUPPORTED: apple-clang-10.0.0
Expand All @@ -17,7 +17,7 @@

#include <cuda/std/chrono>
#include <cuda/std/type_traits>
#include <cassert>
#include <cuda/std/cassert>

#include "test_macros.h"

Expand All @@ -34,7 +34,7 @@ int main(int, char**)
}

{
using namespace std::literals;
using namespace cuda::std::literals;
ASSERT_NOEXCEPT( 4d);
ASSERT_SAME_TYPE(cuda::std::chrono::day, decltype(4d));

Expand Down
6 changes: 0 additions & 6 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,6 @@ typedef __char32_t char32_t;

#define _LIBCUDACXX_ALWAYS_INLINE __attribute__ ((__always_inline__))

// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1
#if (defined(_LIBCUDACXX_CLANG_VER) && _LIBCUDACXX_CLANG_VER < 800) || \
(defined(__apple_build_version__) && __apple_build_version__ < 10010000)
#define _LIBCUDACXX_HAS_NO_CXX20_CHRONO_LITERALS
#endif

#if __has_feature(cxx_reference_qualified_functions)
#define _LIBCUDACXX_HAS_REFERENCE_QUALIFIED_FUNCTIONS
#endif
Expand Down
6 changes: 2 additions & 4 deletions libcxx/include/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -3270,19 +3270,17 @@ inline namespace literals
return chrono::duration<long double, nano> (__ns);
}

#if _LIBCUDACXX_STD_VER > 17 && !defined(_LIBCUDACXX_HAS_NO_CXX20_CHRONO_LITERALS)
_LIBCUDACXX_INLINE_VISIBILITY
constexpr chrono::day operator ""d(unsigned long long __d) noexcept
constexpr chrono::day operator""d(unsigned long long __d) noexcept
{
return chrono::day(static_cast<unsigned>(__d));
}

_LIBCUDACXX_INLINE_VISIBILITY
constexpr chrono::year operator ""y(unsigned long long __y) noexcept
constexpr chrono::year operator""y(unsigned long long __y) noexcept
{
return chrono::year(static_cast<int>(__y));
}
#endif
}}

namespace chrono { // hoist the literals into namespace std::chrono
Expand Down

0 comments on commit 3f388de

Please sign in to comment.