C2064 术语不会计算为采用 1 个参数的函数

问题描述 投票:0回答:1

我目前正在《代码降临》第 2 天进行工作,这是我第一次尝试一些不同的东西。我在路上通过播客听说了 boost split,回家后立即想尝试一下。

我将矢量游戏作为输出、输入游戏集和分隔符 ;。 我希望将游戏中的每个元素打印到控制台,以确保我的元素正确。

    #include <iostream>
    #include <fstream>
    #include <string>
    #include <boost/algorithm/string.hpp>
    #include <vector>

    vector<std::string> games;

    void partOneAnswer() {

        // Open File
        std::string filePath = "test_values.txt";
        std::ifstream stream(filePath);
        std::string line;

        if (stream.is_open()) {
            while (std::getline(stream, line)) {

                // printf("%s\n", line.c_str());
                std::string delimiter = ":";
                std::string gameSets = line.substr(line.find(delimiter) + 2, line.length());
                //printf("%s\n", gameSets.c_str());

                while (gameSets != "") {
                    // place each set into a vector, being delimited by ;
                    boost::split(games, gameSets, ";");
                    for (int i = 0; i < games.size(); i++) {
                        std::cout << games[i] + "\n";
                    }
                }
            }
        }
    }

结果是错误。 有什么想法吗?

错误将我带到: oost 算法\字符串\详细信息inder.hpp 578

在我添加 boost 之前,编译不是问题。

c++ boost split compiler-errors
1个回答
1
投票

boost::split 需要一个谓词作为其分隔符,不能使用字符串:

boost::split(games, gameSets, boost::is_any_of(";"))
© www.soinside.com 2019 - 2024. All rights reserved.