1919namespace rsl ::_format_impl {
2020
2121struct FormatResult {
22- using join_t = std::string (FormatResult:: *)(StyleMap const *) const ;
23- join_t join;
22+ using join_t = std::string (*)(StyleMap const *);
23+ join_t join = nullptr ;
2424
2525 template <auto ... Args>
26- std::string join_impl (StyleMap const * style_map) const {
26+ static std::string join_impl (std::string_view raw, StyleMap const * style_map) {
2727 static constexpr Style::Tag style_tags[] = {Args...};
2828
2929 std::string result;
@@ -39,24 +39,32 @@ struct FormatResult {
3939 return result;
4040 }
4141
42+ template <auto ... Args>
43+ constexpr static auto join_impl_ptr = &join_impl<Args...>;
44+
4245 FormatResult (std::string result, join_t joiner) : raw(std::move(result)), join(joiner) {}
4346
4447 std::string raw;
4548 [[nodiscard]] std::string with_style (StyleMap const & style) const {
46- return ( this ->* join) (&style);
49+ return join (&style);
4750 }
48- [[nodiscard]] std::string unstyled () const { return ( this ->* join) (nullptr ); }
51+ [[nodiscard]] std::string unstyled () const { return join (nullptr ); }
4952 [[nodiscard]] constexpr explicit (false ) operator std::string() const { return unstyled (); }
5053};
5154
52- template <rsl::string_view fmt, typename Accessors, std::meta::info Joiner, typename ... Args>
55+
56+
57+ template <rsl::string_view fmt, typename Accessors, /* auto Joiner,*/ typename ... Args>
5358FormatResult format_impl (Args&&... args) {
5459 auto str = [&]<typename ... Xs>(AccessorList<Xs...>) {
5560 return std::format (fmt.data (), Xs::get (std::forward<Args...[Xs::index]>(args...[Xs::index]))...);
5661 }(Accessors{});
57- return FormatResult (str, extract<FormatResult::join_t >(Joiner));
62+ return FormatResult (str, nullptr /* extract<FormatResult::join_t>(Joiner)*/ );
5863}
5964
65+ template <rsl::string_view fmt, typename Accessors, std::meta::info Joiner, typename ... Args>
66+ constexpr auto format_impl_ptr = &format_impl<fmt, Accessors, /* Joiner,*/ Args...>;
67+
6068struct FormatString {
6169 std::string string;
6270 std::vector<Style> style_tags;
@@ -75,10 +83,10 @@ struct FormatString {
7583 for (auto const & style : style_tags) {
7684 join_args.emplace_back (style);
7785 }
78- args.push_back (reflect_constant (substitute (^^FormatResult::join_impl , join_args)));
86+ args.push_back (std::meta:: reflect_constant (substitute (^^FormatResult::join_impl_ptr , join_args)));
7987
8088 (args.push_back (^^Args), ...);
81- return extract<format_type<Args...>>(substitute (^^format_impl , args));
89+ return extract<format_type<Args...>>(substitute (^^format_impl_ptr , args));
8290 }
8391};
8492
0 commit comments