2
我需要爲MFC項目編寫一些代碼,但我不知道如何在使用MFC時獲取所需的代碼。使用CString與提升字符串算法 - 減少到一個typedef?
我首先使用STL類型和boost來初始化我的函數。
STL原型
#include <string>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/find.hpp>
void ProtoTest()
{
std::string sText("123Hello4");
boost::iterator_range<std::string::iterator> nc_result = find_token(sText, boost::algorithm::is_alpha(), boost::algorithm ::token_compress_on);
}
結果= 「你好」
我終於設法得到它與MFC的工作,但是我必須提供兩個類型定義。我想在一個,但沒有太多的使用boost提供的MFC端口的文檔。
#include "stdafx.h"
#include <boost\range\atl.hpp>
void Test()
{
typedef boost::range_iterator<CString>::type CString_it;
typedef boost::iterator_range<CString_it> CString_range;
CString strText("123Hello4");
CString_range r;
r = find_token(text, boost::algorithm::is_alpha(), boost::algorithm ::token_compress_on);
}
再次結果=「你好」
是否有一個單一的typedef我可以用持有的find_token的結果,而不需要2個typdefs去實現它。
問題是當使用MFC字符串時,應該提供單個typedef來保存find_token的答案。 –