“抛出 'std::bad_alloc' 的实例后调用终止”是什么意思?

What does 'terminate called after throwing an instance of 'std::bad_alloc' ' mean?

我正在编写一个函数,它可以打开一个文本文件并读取每一行,然后将其添加到一个字符串向量中(每行只是一个单词)。代码编译但在我尝试 运行 时以错误终止。

这是我在调用函数并尝试打印向量后遇到的错误:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted

如果我调用函数但不打印向量,我会得到 Segmentation Fault

我在网上查了这个错误,但找不到它的确切含义。从我所看到的看来,这个错误似乎与使用过多内存有关。也许我的代码中有什么东西导致了无限循环??这个错误到底是什么意思,它如何应用于我编写的代码?

 vector<string> readToVector(string fileTo) {
        vector<string> setVector;
        string temp;
        ifstream openSet(fileTo.c_str());
        if (openSet.is_open()) {
            while ( getline (openSet,temp) ) {
                    setVector.push_back(temp);
            }
        }
        else {
            cout << "Unable to open set file." << endl;
        }
    }

算了,我傻。我只是从来没有在我的函数中返回向量。 捂脸