| 1 |
// -*- C++ -*- |
| 2 |
//===----------------------------------------------------------------------===// |
| 3 |
// |
| 4 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 |
// See https://llvm.org/LICENSE.txt for license information. |
| 6 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP |
| 11 |
#define SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP |
| 12 |
|
| 13 |
// Contains helper functions to create a std::chrono::leap_second. |
| 14 |
// |
| 15 |
// Since the standard doesn't specify how a @ref std::chrono::leap_second is |
| 16 |
// constructed this is implementation defined. To make the public API tests of |
| 17 |
// the class generic this header defines helper functions to create the |
| 18 |
// required object. |
| 19 |
// |
| 20 |
// Note This requires every standard library implementation to write their own |
| 21 |
// helper function. Vendors are encouraged to create a pull request at |
| 22 |
// https://github.com/llvm/llvm-project so their specific implementation can be |
| 23 |
// part of this file. |
| 24 |
|
| 25 |
#include "test_macros.h" |
| 26 |
|
| 27 |
#if TEST_STD_VER < 20 |
| 28 |
# error "The format header requires at least C++20" |
| 29 |
#endif |
| 30 |
|
| 31 |
#include <chrono> |
| 32 |
|
| 33 |
#ifdef _LIBCPP_VERSION |
| 34 |
|
| 35 |
# include <__utility/private_constructor_tag.h> |
| 36 |
|
| 37 |
inline constexpr std::chrono::leap_second |
| 38 |
test_leap_second_create(const std::chrono::sys_seconds& date, const std::chrono::seconds& value) { |
| 39 |
return std::chrono::leap_second{std::__private_constructor_tag{}, date, value}; |
| 40 |
} |
| 41 |
|
| 42 |
#else // _LIBCPP_VERSION |
| 43 |
# error \ |
| 44 |
"Please create a vendor specific version of the test typedef and file a PR at https://github.com/llvm/llvm-project" |
| 45 |
#endif // _LIBCPP_VERSION |
| 46 |
|
| 47 |
#endif // SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP |