tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
basic_format_args.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2023 Tobias Hienzsch
3
4#ifndef TETL_FORMAT_BASIC_FORMAT_ARGS_HPP
5#define TETL_FORMAT_BASIC_FORMAT_ARGS_HPP
6
7#include <etl/_cstddef/size_t.hpp>
8#include <etl/_format/basic_format_arg.hpp>
9#include <etl/_format/basic_format_context.hpp>
10#include <etl/_format/format_arg_store.hpp>
11#include <etl/_span/span.hpp>
12
13namespace etl {
14
15template <typename Context>
17 constexpr basic_format_args() noexcept = default;
18
19 template <typename... Args>
20 constexpr basic_format_args(detail::format_arg_store<Context, Args...> const& store) noexcept
21 : _args{store.args}
22 {
23 }
24
25 [[nodiscard]] constexpr auto get(size_t i) const noexcept -> basic_format_arg<Context>
26 {
27 if (i >= _args.size()) {
28 return basic_format_arg<Context>{};
29 }
30 return _args[i];
31 }
32
33private:
34 span<basic_format_arg<Context> const> _args;
35};
36
37using format_args = basic_format_args<format_context>;
38using wformat_args = basic_format_args<wformat_context>;
39
40} // namespace etl
41
42#endif // TETL_FORMAT_BASIC_FORMAT_ARGS_HPP
Definition adjacent_find.hpp:9
Definition basic_format_args.hpp:16
constexpr basic_format_args() noexcept=default
constexpr auto get(size_t i) const noexcept -> basic_format_arg< Context >
Definition basic_format_args.hpp:25
constexpr basic_format_args(detail::format_arg_store< Context, Args... > const &store) noexcept
Definition basic_format_args.hpp:20