SDK  2.1.4 [async]
CloudBackend Software Development Kit - SDK API for C++
buildMsg.h
1 #ifndef CBE__impl__buildMsg_h__
2 #define CBE__impl__buildMsg_h__
3 
4 #include <sstream>
5 
6 namespace cbe {
7  namespace util {
8  namespace impl {
9 
10 template <typename T, typename... Ts>
11 void buildMsgImpl(std::ostream& os, T&& arg, Ts&&... restArgs);
12 
13  } // namespace impl
14 
15 
16 template <typename T, typename... Ts>
17 std::ostream& buildMsg(std::ostream& os, T&& arg, Ts&&... restArgs) {
18  impl::buildMsgImpl(os, std::forward<T>(arg), std::forward<Ts>(restArgs)...);
19  return os;
20 }
21 
22 template <typename T, typename... Ts>
23 typename std::enable_if<!std::is_base_of<std::ostream,
24  typename std::remove_reference<T>::type
25  >::value, std::string>::type
26 buildMsg(T&& arg, Ts&&... restArgs) {
27  std::ostringstream oss;
28  buildMsg(oss /* os */, std::forward<T>(arg), std::forward<Ts>(restArgs)...);
29  return oss.str();
30 }
31 
32 namespace impl {
33 
34 void buildMsgImpl(std::ostream&);
35 
36 template <typename T, typename... Ts>
37  void buildMsgImpl(std::ostream& os, T&& arg, Ts&&... restArgs) {
38  os << std::forward<T>(arg);
39  buildMsgImpl(os, std::forward<Ts>(restArgs)...);
40 }
41 
42  } // namespace impl
43  } // namespace util
44 } // namespace cbe
45 
46 
47 #endif // #ifndef CBE__impl__buildMsg_h__
Root namespace for the CloudBackend SDK API.
Definition: Account.h:22