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-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef _LIBCPP___FORMAT_FORMAT_ARGS_H 11 #define _LIBCPP___FORMAT_FORMAT_ARGS_H 12 13 #include <__availability> 14 #include <__config> 15 #include <__format/format_fwd.h> 16 #include <cstddef> 17 18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 19 # pragma GCC system_header 20 #endif 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 #if _LIBCPP_STD_VER > 17 25 26 template <class _Context> 27 class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args { 28 public: 29 // TODO FMT Implement [format.args]/5 30 // [Note 1: Implementations are encouraged to optimize the representation of 31 // basic_format_args for small number of formatting arguments by storing 32 // indices of type alternatives separately from values and packing the 33 // former. - end note] 34 // Note: Change __format_arg_store to use a built-in array. 35 _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default; 36 37 template <class... _Args> 38 _LIBCPP_HIDE_FROM_ABI basic_format_args( 39 const __format_arg_store<_Context, _Args...>& __store) noexcept 40 : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {} 41 42 _LIBCPP_HIDE_FROM_ABI 43 basic_format_arg<_Context> get(size_t __id) const noexcept { 44 return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{}; 45 } 46 47 _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; } 48 49 private: 50 size_t __size_{0}; 51 const basic_format_arg<_Context>* __data_{nullptr}; 52 }; 53 54 #endif //_LIBCPP_STD_VER > 17 55 56 _LIBCPP_END_NAMESPACE_STD 57 58 #endif // _LIBCPP___FORMAT_FORMAT_ARGS_H 59