48 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP11#define SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP12 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 is16// constructed this is implementation defined. To make the public API tests of17// the class generic this header defines helper functions to create the18// required object.19//20// Note This requires every standard library implementation to write their own21// helper function. Vendors are encouraged to create a pull request at22// https://github.com/llvm/llvm-project so their specific implementation can be23// part of this file.24 25#include "test_macros.h"26 27#if TEST_STD_VER < 2028# error "The format header requires at least C++20"29#endif30 31#include <chrono>32 33#ifdef _LIBCPP_VERSION34 35# include <__utility/private_constructor_tag.h>36 37inline constexpr std::chrono::leap_second38test_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_VERSION43# 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_VERSION46 47#endif // SUPPORT_TEST_CHRONO_LEAP_SECOND_HPP48