8#ifndef INCLUDED_BSLFMT_FORMAT
9#define INCLUDED_BSLFMT_FORMAT
466#include <bslscm_version.h>
470#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_FORMAT)
480#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_FORMAT)
496#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_FORMAT)
500 #include <string_view>
501 #include <type_traits>
504#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
508#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_FORMAT)
511using BloombergLP::bslfmt::basic_format_arg;
512using BloombergLP::bslfmt::basic_format_args;
513using BloombergLP::bslfmt::basic_format_context;
514using BloombergLP::bslfmt::basic_format_parse_context;
515using BloombergLP::bslfmt::basic_format_string;
516using BloombergLP::bslfmt::format;
517using BloombergLP::bslfmt::format_args;
518using BloombergLP::bslfmt::format_context;
519using BloombergLP::bslfmt::format_error;
520using BloombergLP::bslfmt::format_parse_context;
521using BloombergLP::bslfmt::format_string;
522using BloombergLP::bslfmt::format_to;
523using BloombergLP::bslfmt::format_to_n;
524using BloombergLP::bslfmt::format_to_n_result;
525using BloombergLP::bslfmt::formatted_size;
526using BloombergLP::bslfmt::make_format_args;
527using BloombergLP::bslfmt::make_wformat_args;
528using BloombergLP::bslfmt::vformat;
529using BloombergLP::bslfmt::vformat_to;
530using BloombergLP::bslfmt::visit_format_arg;
531using BloombergLP::bslfmt::wformat_args;
532using BloombergLP::bslfmt::wformat_context;
533using BloombergLP::bslfmt::wformat_parse_context;
534using BloombergLP::bslfmt::wformat_string;
543using std::basic_format_arg;
544using std::basic_format_args;
545using std::basic_format_context;
546using std::basic_format_parse_context;
547using std::basic_format_string;
549using std::format_args;
550using std::format_context;
551using std::format_error;
552using std::format_parse_context;
553using std::format_string;
555using std::format_to_n;
556using std::format_to_n_result;
557using std::formatted_size;
561using std::vformat_to;
562using std::visit_format_arg;
563using std::wformat_args;
564using std::wformat_context;
565using std::wformat_parse_context;
566using std::wformat_string;
573template <
class... t_ARGS>
574string format(format_string<t_ARGS...> fmtStr, t_ARGS&&... args);
579template <
class... t_ARGS>
580wstring format(wformat_string<t_ARGS...> fmtStr, t_ARGS&&... args);
585template <
class... t_ARGS>
586string format(
const std::locale& loc,
587 format_string<t_ARGS...> fmtStr,
593template <
class... t_ARGS>
595 wformat_string<t_ARGS...> fmtStr,
602template <
class... t_ARGS>
603string format(allocator<char> alloc,
604 format_string<t_ARGS...> fmtStr,
611template <
class... t_ARGS>
613 wformat_string<t_ARGS...> fmtStr,
620template <
class... t_ARGS>
621string format(allocator<char> alloc,
622 const std::locale& loc,
623 format_string<t_ARGS...> fmtStr,
630template <
class... t_ARGS>
632 const std::locale& loc,
633 wformat_string<t_ARGS...> fmtStr,
641template <
class t_CONTEXT = std::format_context,
class... t_ARGS>
649template <
class... t_ARGS>
661template <
class t_STRING,
class... t_ARGS>
662requires(bsl::is_same_v<t_STRING, bsl::string>)
664 format_string<t_ARGS...> fmtStr,
676template <
class t_STRING,
class... t_ARGS>
677requires(bsl::is_same_v<t_STRING, bsl::wstring>)
679 wformat_string<t_ARGS...> fmtStr,
692template <
class t_STRING,
class... t_ARGS>
693requires(bsl::is_same_v<t_STRING, bsl::string>)
695 const std::locale& loc,
696 format_string<t_ARGS...> fmtStr,
709template <
class t_STRING,
class... t_ARGS>
710requires(bsl::is_same_v<t_STRING, bsl::wstring>)
712 const std::locale& loc,
713 wformat_string<t_ARGS...> fmtStr,
719string vformat(std::string_view fmtStr, format_args args);
729string vformat(
const std::locale& loc,
730 std::string_view fmtStr,
737 std::wstring_view fmtStr,
744string vformat(allocator<char> alloc,
745 std::string_view fmtStr,
753 std::wstring_view fmtStr,
760string vformat(allocator<char> alloc,
761 const std::locale& loc,
762 std::string_view fmtStr,
770 const std::locale& loc,
771 std::wstring_view fmtStr,
782void vformat_to(
string *out, std::string_view fmtStr, format_args args);
804 const std::locale& loc,
805 std::string_view fmtStr,
818 const std::locale& loc,
819 std::wstring_view fmtStr,
829template <
class t_CONTEXT,
class... t_ARGS>
830auto bsl::make_format_args(t_ARGS&... args)
833 (... && (!std::is_same_v<std::decay_t<t_ARGS>,
long double>)),
834 "long double is not supported in bsl::format");
835 return std::make_format_args<t_CONTEXT>(args...);
838template <
class... t_ARGS>
839auto bsl::make_wformat_args(t_ARGS&... args)
842 (... && (!std::is_same_v<std::decay_t<t_ARGS>,
long double>)),
843 "long double is not supported in bsl::format");
844 return std::make_wformat_args(args...);
847template <
class... t_ARGS>
848bsl::string bsl::format(format_string<t_ARGS...> fmtStr, t_ARGS&&... args)
850 return bsl::vformat(fmtStr.get(),
851 bsl::make_format_args(args...));
854template <
class... t_ARGS>
855bsl::wstring bsl::format(wformat_string<t_ARGS...> fmtStr, t_ARGS&&... args)
857 return bsl::vformat(fmtStr.get(),
858 bsl::make_wformat_args(args...));
861template <
class... t_ARGS>
863 format_string<t_ARGS...> fmtStr,
866 return bsl::vformat(loc,
868 bsl::make_format_args(args...));
871template <
class... t_ARGS>
873 wformat_string<t_ARGS...> fmtStr,
876 return bsl::vformat(loc,
878 bsl::make_wformat_args(args...));
881template <
class... t_ARGS>
883 format_string<t_ARGS...> fmtStr,
886 return bsl::vformat(alloc,
888 bsl::make_format_args(args...));
891template <
class... t_ARGS>
893 wformat_string<t_ARGS...> fmtStr,
896 return bsl::vformat(alloc,
898 bsl::make_wformat_args(args...));
901template <
class... t_ARGS>
903 const std::locale& loc,
904 format_string<t_ARGS...> fmtStr,
907 return bsl::vformat(alloc,
910 bsl::make_format_args(args...));
913template <
class... t_ARGS>
915 const std::locale& loc,
916 wformat_string<t_ARGS...> fmtStr,
919 return bsl::vformat(alloc,
922 bsl::make_wformat_args(args...));
926bsl::string bsl::vformat(std::string_view fmt, format_args args)
929 bsl::vformat_to(&result, fmt, args);
934bsl::wstring bsl::vformat(std::wstring_view fmt, wformat_args args)
937 bsl::vformat_to(&result, fmt, args);
943 std::string_view fmt,
947 bsl::vformat_to(&result, loc, fmt, args);
953 std::wstring_view fmt,
957 bsl::vformat_to(&result, loc, fmt, args);
963 std::string_view fmt,
966 string result(alloc);
967 bsl::vformat_to(&result, fmt, args);
973 std::wstring_view fmt,
977 bsl::vformat_to(&result, fmt, args);
983 const std::locale& loc,
984 std::string_view fmt,
987 string result(alloc);
988 bsl::vformat_to(&result, loc, fmt, args);
994 const std::locale& loc,
995 std::wstring_view fmt,
999 bsl::vformat_to(&result, loc, fmt, args);
1003template <
class t_STRING,
class... t_ARGS>
1004requires(bsl::is_same_v<t_STRING, bsl::string>)
1005void bsl::format_to(t_STRING *out,
1006 format_string<t_ARGS...> fmtStr,
1009 bsl::vformat_to(out,
1011 bsl::make_format_args(args...));
1014template <
class t_STRING,
class... t_ARGS>
1015requires(bsl::is_same_v<t_STRING, bsl::wstring>)
1016void bsl::format_to(t_STRING *out,
1017 wformat_string<t_ARGS...> fmtStr,
1020 bsl::vformat_to(out,
1022 bsl::make_wformat_args(args...));
1025template <
class t_STRING,
class... t_ARGS>
1026requires(bsl::is_same_v<t_STRING, bsl::string>)
1027void bsl::format_to(t_STRING *out,
1028 const std::locale& loc,
1029 format_string<t_ARGS...> fmtStr,
1032 bsl::vformat_to(out,
1035 bsl::make_format_args(args...));
1038template <
class t_STRING,
class... t_ARGS>
1039requires(bsl::is_same_v<t_STRING, bsl::wstring>)
1040void bsl::format_to(t_STRING *out,
1041 const std::locale& loc,
1042 wformat_string<t_ARGS...> fmtStr,
1045 bsl::vformat_to(out,
1048 bsl::make_wformat_args(args...));
1053void bsl::vformat_to(
string *out, std::string_view fmt, format_args args)
1056 std::vformat_to(std::back_inserter(*out), fmt, args);
1060void bsl::vformat_to(wstring *out, std::wstring_view fmt, wformat_args args)
1063 std::vformat_to(std::back_inserter(*out), fmt, args);
1067void bsl::vformat_to(
string *out,
1068 const std::locale& loc,
1069 std::string_view fmt,
1073 std::vformat_to(std::back_inserter(*out), loc, fmt, args);
1077void bsl::vformat_to(wstring *out,
1078 const std::locale& loc,
1079 std::wstring_view fmt,
1083 std::vformat_to(std::back_inserter(*out), loc, fmt, args);
Definition bslstl_string.h:1252
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlat_valuetypefunctions.h:939
basic_string< wchar_t > wstring
Definition bslstl_string.h:845
bsl::string vformat(bsl::string_view fmt, format_args args)
Definition bslfmt_format_imp.h:1006
bsl::enable_if<!bsl::is_same< typenamebsl::decay< t_OUT >::type, bsl::string * >::value, t_OUT >::type format_to(t_OUT out, BSLFMT_FORMAT_STRING_PARAMETER fmtStr, const t_ARGS &... args)
Definition bslfmt_format_imp.h:1046
Format_ArgsStore< format_context, t_ARGS... > make_format_args(t_ARGS &... fmt_args)
Definition bslfmt_format_args.h:461
bsl::string format(BSLFMT_FORMAT_STRING_PARAMETER fmtStr, const t_ARGS &... args)
Definition bslfmt_format_imp.h:1085
t_OUT vformat_to(t_OUT out, bsl::string_view fmtStr, format_args args)
Definition bslfmt_format_imp.h:981
Format_ArgsStore< wformat_context, t_ARGS... > make_wformat_args(t_ARGS &... fmt_args)
Definition bslfmt_format_args.h:469