Boostを使用して時間をトークン化しようとしています。5:00 PM
入出力したい<5> <00> <PM>
。問題は、私があらゆる種類のことを試したことですが、出力のみ<5> <00>
です。ただし、を入力する5:00PM
と、出力が得られます<5> <00PM>
。ブーストにスペースをトークンとして受け入れるようにするにはどうすればよいですか (:)? PM が 00 とスペースで区切られている場合、PM をスローし続けます。
#include "stdafx.h"
#include <iostream>
#include <boost/tokenizer.hpp>
#include <string>
#include <stdlib.h>
#include <boost/algorithm/string.hpp>
using namespace std;
int main(){
string str1;
cin >> str1;
typedef boost::tokenizer<boost::char_separator<char> >
tokenizer;
boost::char_separator<char> sep(":\t ");
string t1 (str1);
tokenizer tokens1(t1, sep);
for (tokenizer::iterator tok_iter = tokens1.begin();
tok_iter != tokens1.end(); tok_iter++)
{cout << "<" << *tok_iter << "> ";}
system("pause");
return 0;
}