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___FORMAT_FORMAT_ARGS_H
11 #define _LIBCPP___FORMAT_FORMAT_ARGS_H
13 #include <__availability>
15 #include <__format/format_fwd.h>
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 #pragma GCC system_header
23 #include <__undef_macros>
25 _LIBCPP_BEGIN_NAMESPACE_STD
27 #if _LIBCPP_STD_VER > 17
29 // TODO FMT Remove this once we require compilers with proper C++20 support.
30 // If the compiler has no concepts support, the format header will be disabled.
31 // Without concepts support enable_if needs to be used and that too much effort
32 // to support compilers with partial C++20 support.
33 #if !defined(_LIBCPP_HAS_NO_CONCEPTS)
35 template <class _Context>
36 class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args {
38 // TODO FMT Implement [format.args]/5
39 // [Note 1: Implementations are encouraged to optimize the representation of
40 // basic_format_args for small number of formatting arguments by storing
41 // indices of type alternatives separately from values and packing the
42 // former. - end note]
43 // Note: Change __format_arg_store to use a built-in array.
44 _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default;
46 template <class... _Args>
47 _LIBCPP_HIDE_FROM_ABI basic_format_args(
48 const __format_arg_store<_Context, _Args...>& __store) noexcept
49 : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {}
52 basic_format_arg<_Context> get(size_t __id) const noexcept {
53 return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{};
56 _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; }
60 const basic_format_arg<_Context>* __data_{nullptr};
63 #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
65 #endif //_LIBCPP_STD_VER > 17
67 _LIBCPP_END_NAMESPACE_STD
71 #endif // _LIBCPP___FORMAT_FORMAT_ARGS_H