Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C2064 term does not evaluate to a function taking 1 arguments

I am currently working on Advent of Code day 2 and I am trying out some different stuff for the first time. I heard about boost split through a podcast while on the road and immediately wanted to give it a go when I got home.

I have my vector games as the output, the input gameSets, and the delimiter ;.
I was hoping to print each element within games to the console to ensure my elements were correct.

#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";
                }
            }
        }
    }
}

The result was the error.
Any ideas on why?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Error takes me to:

\boost\algorithm\string\detail\finder.hpp 578

Compiling was not an issue until I added boost.

>Solution :

boost::split needs a predicate for its delimiter, you can’t use a string:

boost::split(games, gameSets, boost::is_any_of(";"))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading