2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___CHRONO_STATICALLY_WIDEN_H
11 #define _LIBCPP___CHRONO_STATICALLY_WIDEN_H
13 // Implements the STATICALLY-WIDEN exposition-only function. ([time.general]/2)
15 #include <__concepts/same_as.h>
17 #include <__format/concepts.h>
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 # pragma GCC system_header
23 _LIBCPP_BEGIN_NAMESPACE_STD
25 #if _LIBCPP_STD_VER >= 20
27 # if _LIBCPP_HAS_WIDE_CHARACTERS
28 template <__fmt_char_type _CharT
>
29 _LIBCPP_HIDE_FROM_ABI
constexpr const _CharT
* __statically_widen(const char* __str
, const wchar_t* __wstr
) {
30 if constexpr (same_as
<_CharT
, char>)
35 # define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)
36 # else // _LIBCPP_HAS_WIDE_CHARACTERS
38 // Without this indirection the unit test test/libcxx/modules_include.sh.cpp
39 // fails for the CI build "No wide characters". This seems like a bug.
40 // TODO FMT investigate why this is needed.
41 template <__fmt_char_type _CharT
>
42 _LIBCPP_HIDE_FROM_ABI
constexpr const _CharT
* __statically_widen(const char* __str
) {
45 # define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)
46 # endif // _LIBCPP_HAS_WIDE_CHARACTERS
48 #endif // _LIBCPP_STD_VER >= 20
50 _LIBCPP_END_NAMESPACE_STD
52 #endif // _LIBCPP___CHRONO_STATICALLY_WIDEN_H