format_string.h 747 B

1234567891011121314151617181920212223242526
  1. #pragma once
  2. #include <util/generic/strbuf.h>
  3. #include <util/generic/string.h>
  4. #include <util/string/builder.h>
  5. namespace NYsonPull {
  6. namespace NDetail {
  7. namespace NImpl {
  8. inline void apply_args(TStringBuilder&) {
  9. }
  10. template <typename T, typename... Args>
  11. inline void apply_args(TStringBuilder& builder, T&& arg, Args&&... args) {
  12. apply_args(builder << arg, std::forward<Args>(args)...);
  13. }
  14. }
  15. template <typename... Args>
  16. TString format_string(Args&&... args) {
  17. TStringBuilder builder;
  18. NImpl::apply_args(builder, std::forward<Args>(args)...);
  19. return TString(std::move(builder));
  20. }
  21. }
  22. }