xref: /freebsd/contrib/llvm-project/libcxx/include/__chrono/statically_widen.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1bdd1243dSDimitry Andric // -*- C++ -*-
2bdd1243dSDimitry Andric //===----------------------------------------------------------------------===//
3bdd1243dSDimitry Andric //
4bdd1243dSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5bdd1243dSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
6bdd1243dSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7bdd1243dSDimitry Andric //
8bdd1243dSDimitry Andric //===----------------------------------------------------------------------===//
9bdd1243dSDimitry Andric 
10bdd1243dSDimitry Andric #ifndef _LIBCPP___CHRONO_STATICALLY_WIDEN_H
11bdd1243dSDimitry Andric #define _LIBCPP___CHRONO_STATICALLY_WIDEN_H
12bdd1243dSDimitry Andric 
13bdd1243dSDimitry Andric // Implements the STATICALLY-WIDEN exposition-only function. ([time.general]/2)
14bdd1243dSDimitry Andric 
15bdd1243dSDimitry Andric #include <__concepts/same_as.h>
16bdd1243dSDimitry Andric #include <__config>
17bdd1243dSDimitry Andric #include <__format/concepts.h>
18bdd1243dSDimitry Andric 
19bdd1243dSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20bdd1243dSDimitry Andric #  pragma GCC system_header
21bdd1243dSDimitry Andric #endif
22bdd1243dSDimitry Andric 
23bdd1243dSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
24bdd1243dSDimitry Andric 
25*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20
26bdd1243dSDimitry Andric 
27bdd1243dSDimitry Andric #  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
28bdd1243dSDimitry Andric template <__fmt_char_type _CharT>
__statically_widen(const char * __str,const wchar_t * __wstr)29bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str, const wchar_t* __wstr) {
30bdd1243dSDimitry Andric   if constexpr (same_as<_CharT, char>)
31bdd1243dSDimitry Andric     return __str;
32bdd1243dSDimitry Andric   else
33bdd1243dSDimitry Andric     return __wstr;
34bdd1243dSDimitry Andric }
35bdd1243dSDimitry Andric #    define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)
36bdd1243dSDimitry Andric #  else // _LIBCPP_HAS_NO_WIDE_CHARACTERS
37bdd1243dSDimitry Andric 
38bdd1243dSDimitry Andric // Without this indirection the unit test test/libcxx/modules_include.sh.cpp
39bdd1243dSDimitry Andric // fails for the CI build "No wide characters". This seems like a bug.
40bdd1243dSDimitry Andric // TODO FMT investigate why this is needed.
41bdd1243dSDimitry Andric template <__fmt_char_type _CharT>
42bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str) {
43bdd1243dSDimitry Andric   return __str;
44bdd1243dSDimitry Andric }
45bdd1243dSDimitry Andric #    define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)
46bdd1243dSDimitry Andric #  endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
47bdd1243dSDimitry Andric 
48*06c3fb27SDimitry Andric #endif //_LIBCPP_STD_VER >= 20
49bdd1243dSDimitry Andric 
50bdd1243dSDimitry Andric _LIBCPP_END_NAMESPACE_STD
51bdd1243dSDimitry Andric 
52bdd1243dSDimitry Andric #endif // _LIBCPP___CHRONO_STATICALLY_WIDEN_H
53