microsoft/onnxruntime-extensions
Publicmirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable
ocos/utils.h
23lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | #pragma once |
| 4 | #include <iostream> |
| 5 | #include <sstream> |
| 6 | |
| 7 | template <typename T> |
| 8 | inline void MakeStringInternal(std::ostringstream& ss, const T& t) noexcept { |
| 9 | ss << t; |
| 10 | } |
| 11 | |
| 12 | template <typename T, typename... Args> |
| 13 | void MakeStringInternal(std::ostringstream& ss, const T& t, const Args&... args) noexcept { |
| 14 | MakeStringInternal(ss, t); |
| 15 | MakeStringInternal(ss, args...); |
| 16 | } |
| 17 | |
| 18 | template <typename... Args> |
| 19 | std::string MakeString(const Args&... args) { |
| 20 | std::ostringstream ss; |
| 21 | MakeStringInternal(ss, args...); |
| 22 | return std::string(ss.str()); |
| 23 | } |
| 24 | |