brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 40e0856 Raw
53 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 _LIBCPP___CHRONO_STATICALLY_WIDEN_H11#define _LIBCPP___CHRONO_STATICALLY_WIDEN_H12 13// Implements the STATICALLY-WIDEN exposition-only function. ([time.general]/2)14 15#include <__concepts/same_as.h>16#include <__config>17#include <__format/concepts.h>18 19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#  pragma GCC system_header21#endif22 23_LIBCPP_BEGIN_NAMESPACE_STD24 25#if _LIBCPP_STD_VER >= 2026 27#  if _LIBCPP_HAS_WIDE_CHARACTERS28template <__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>)31    return __str;32  else33    return __wstr;34}35#    define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)36#  else // _LIBCPP_HAS_WIDE_CHARACTERS37 38// Without this indirection the unit test test/libcxx/modules_include.sh.cpp39// fails for the CI build "No wide characters". This seems like a bug.40// TODO FMT investigate why this is needed.41template <__fmt_char_type _CharT>42_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str) {43  return __str;44}45#    define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)46#  endif // _LIBCPP_HAS_WIDE_CHARACTERS47 48#endif // _LIBCPP_STD_VER >= 2049 50_LIBCPP_END_NAMESPACE_STD51 52#endif // _LIBCPP___CHRONO_STATICALLY_WIDEN_H53