Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:28

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___FORMAT_FORMAT_ARGS_H
0011 #define _LIBCPP___CXX03___FORMAT_FORMAT_ARGS_H
0012 
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__format/format_arg.h>
0015 #include <__cxx03/__format/format_arg_store.h>
0016 #include <__cxx03/__fwd/format.h>
0017 #include <__cxx03/cstddef>
0018 #include <__cxx03/cstdint>
0019 
0020 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 #  pragma GCC system_header
0022 #endif
0023 
0024 _LIBCPP_BEGIN_NAMESPACE_STD
0025 
0026 #if _LIBCPP_STD_VER >= 20
0027 
0028 template <class _Context>
0029 class _LIBCPP_TEMPLATE_VIS basic_format_args {
0030 public:
0031   template <class... _Args>
0032   _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
0033       : __size_(sizeof...(_Args)) {
0034     if constexpr (sizeof...(_Args) != 0) {
0035       if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) {
0036         __values_ = __store.__storage.__values_;
0037         __types_  = __store.__storage.__types_;
0038       } else
0039         __args_ = __store.__storage.__args_;
0040     }
0041   }
0042 
0043   _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> get(size_t __id) const noexcept {
0044     if (__id >= __size_)
0045       return basic_format_arg<_Context>{};
0046 
0047     if (__format::__use_packed_format_arg_store(__size_))
0048       return basic_format_arg<_Context>{__format::__get_packed_type(__types_, __id), __values_[__id]};
0049 
0050     return __args_[__id];
0051   }
0052 
0053   _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; }
0054 
0055 private:
0056   size_t __size_{0};
0057   // [format.args]/5
0058   // [Note 1: Implementations are encouraged to optimize the representation of
0059   // basic_format_args for small number of formatting arguments by storing
0060   // indices of type alternatives separately from values and packing the
0061   // former. - end note]
0062   union {
0063     struct {
0064       const __basic_format_arg_value<_Context>* __values_;
0065       uint64_t __types_;
0066     };
0067     const basic_format_arg<_Context>* __args_;
0068   };
0069 };
0070 
0071 template <class _Context, class... _Args>
0072 basic_format_args(__format_arg_store<_Context, _Args...>) -> basic_format_args<_Context>;
0073 
0074 #endif //_LIBCPP_STD_VER >= 20
0075 
0076 _LIBCPP_END_NAMESPACE_STD
0077 
0078 #endif // _LIBCPP___CXX03___FORMAT_FORMAT_ARGS_H