http://ideone.com/mvb4x5


맵 쓸까 하다가 느리기도 하고 귀찮네유.


#include <iostream>

#include <regex>

#include <string>


using namespace std;


struct  FORMATTER

{

    regex   s_rule;

    string  r_rule;

};


enum    FORMAT_TYPE

{

    test, // 1. 변환 포맷 이름들 ( ex. 통화, 날짜 .... )

};


const   FORMATTER   formats[] =

{

    { regex( "(d{2})(d{3})" ), "$1-$2" }, // 2. 규칙들, 이렇게 두 곳만 수정하면 됨 12345 -> 12-345

};


inline  string  format( const FORMAT_TYPE type, const int value )

{

    return  regex_replace(

            to_string( value ), formats[ type ].s_rule, formats[ type ].r_rule );

};


int main()

{

    cout << format( test, 12345 ) << endl;

    return 0;

}