#include <sstream>

using std::stringstream;
using std::string;

inline void __impl__inlineArgs(stringstream & ss, const string& str, int && from)
{
    if(from != 0)
        ss << str.substr(from);
    else
        ss << str;
}
template<typename T, typename... Args>
inline void __impl__inlineArgs(stringstream & ss, const string& str, const int && from, T t, Args... args)
{
    const auto target = str.find_first_of('$', from);
    if(target == string::npos)
    {
        ss << str.substr(from);
    }
    else
    {
        ss << str.substr(from, target - from) << t;
        __impl__inlineArgs(ss, str, target + 1, args...);
    }
}
template<typename... Args>
inline string inlineArgs(const string str, Args... args)
{
    stringstream ss;
    __impl__inlineArgs(ss, str, 0, args...);
    return ss.str();
}
=================================================
사용방법

inlineArgs("value of userID($) userName($) is $", userId, userName, value[userId]);
=================================================

Posted by Genesis

카테고리

분류 전체보기 (52)
The, 내 생각 (3)
The, 다른 눈 (1)
The, 겔러리 (14)
책 구절 (9)
잡동사니 (13)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

태그목록

달력

«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

글 보관함