format.H 654 B

12345678910111213141516171819202122232425262728
  1. // (c) Daniel Llorens - 2010, 2016
  2. // This library is free software; you can redistribute it and/or modify it under
  3. // the terms of the GNU Lesser General Public License as published by the Free
  4. // Software Foundation; either version 3 of the License, or (at your option) any
  5. // later version.
  6. /// @file format.H
  7. /// @brief Sugar for in-place ostringstream use.
  8. #pragma once
  9. #include <iterator>
  10. #include <iosfwd>
  11. #include <sstream>
  12. template <class ... A> inline std::string
  13. format(A && ... a)
  14. {
  15. std::ostringstream o; (o << ... << a); return o.str();
  16. }
  17. inline decltype(auto)
  18. format(std::string && s)
  19. {
  20. return std::forward<decltype(s)>(s);
  21. }