Skip to content

Commit

Permalink
LWG-3810: CTAD for basic_format_args (#3421)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Casey Carter <Casey@Carter.net>
  • Loading branch information
3 people authored Feb 14, 2023
1 parent aee02b5 commit bf64ffc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,9 @@ private:
const _Format_arg_index* _Index_array = nullptr;
};

template <class _Context, class... _Args>
basic_format_args(_Format_arg_store<_Context, _Args...>) -> basic_format_args<_Context>;

// _Lazy_locale is used instead of a std::locale so that the locale is only
// constructed when needed, and is never constructed if the format string does not
// contain locale-sensitive format specifiers. Note that this means that a new locale
Expand Down
8 changes: 8 additions & 0 deletions tests/std/tests/P0645R10_text_formatting_args/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,19 @@ void test_visit_monostate() {
assert(visit_format_arg(visitor<Context>, basic_format_arg<Context>()) == Arg_type::none);
}

template <class Context>
void test_lwg3810() {
[[maybe_unused]] auto args_store = make_format_args<Context>(1, 2, 3);
static_assert(same_as<decltype(basic_format_args{args_store}), basic_format_args<Context>>);
}

int main() {
test_basic_format_arg<format_context>();
test_basic_format_arg<wformat_context>();
test_format_arg_store<format_context>();
test_format_arg_store<wformat_context>();
test_visit_monostate<format_context>();
test_visit_monostate<wformat_context>();
test_lwg3810<format_context>();
test_lwg3810<wformat_context>();
}

0 comments on commit bf64ffc

Please sign in to comment.