小编hjb*_*reg的帖子

c ++ stringstream太慢了,怎么加快?

可能重复:
在C++中从文本文件中读取数值的最快方法(在这种情况下为double)

#include <ctime>
#include <cstdlib>
#include <string>
#include <sstream>
#include <iostream>
#include <limits>

using namespace std;

static const double NAN_D = numeric_limits<double>::quiet_NaN();

void die(const char *msg, const char *info)
{
    cerr << "** error: " << msg << " \"" << info << '\"';
    exit(1);
}

double str2dou1(const string &str)
{
    if (str.empty() || str[0]=='?') return NAN_D;
    const char *c_str = str.c_str();
    char *err;
    double x = strtod(c_str, &err);
    if (*err != 0) die("unrecognized numeric data", c_str);
    return x; …
Run Code Online (Sandbox Code Playgroud)

c++ performance parsing

18
推荐指数
4
解决办法
2万
查看次数

标签 统计

c++ ×1

parsing ×1

performance ×1