ONE - On-device Neural Engine
Loading...
Searching...
No Matches
str.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __PEPPER_STR_H__
18#define __PEPPER_STR_H__
19
20#include <ostream>
21#include <sstream>
22
23#include <string>
24
25namespace pepper
26{
27namespace details
28{
29
30template <typename... Arg> void str_impl(std::ostream &os, Arg &&...args);
31
32template <> inline void str_impl(std::ostream &)
33{
34 // DO NOTHING
35 return;
36}
37
38template <typename Arg> inline void str_impl(std::ostream &os, Arg &&arg)
39{
40 os << std::forward<Arg>(arg);
41}
42
43template <typename Arg, typename... Args>
44inline void str_impl(std::ostream &os, Arg &&arg, Args &&...args)
45{
46 str_impl(os, std::forward<Arg>(arg));
47 str_impl(os, std::forward<Args>(args)...);
48}
49
50} // namespace details
51} // namespace pepper
52
53namespace pepper
54{
55
56template <typename... Args> static inline std::string str(Args &&...args)
57{
58 std::stringstream ss;
59 details::str_impl(ss, std::forward<Args>(args)...);
60 return ss.str();
61}
62
63} // namespace pepper
64
65#endif // __PEPPER_STR_H__
str
Definition infer.py:18
void str_impl(std::ostream &os, Arg &&...args)