1

我在 Visual Studio 2013 上遇到 C++ 编译器问题。我正在为 C++ 11 标准学习 C++,并且我得到的这个程序可以在所有其他 C++ 11 编译器上完美编译。

然而,VS 2013 给了我问题。它告诉我Error: identifier "not" is undefined(它// line 36在代码中的位置)。我不知道如何解决这个问题。我试图检查宏,但编译时仍然遇到问题:

///     Sort the standard input alphabetically.
/*    Read lines of text, sort them, and print the results to the standard output.
     If the command line names a file, read from that file. Otherwise, read from
   the standard input. The entire input is stored in memory, so don’t try
    this with input files that exceed available RAM.
*/
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
void read(std::istream& in, std::vector<std::string>& text)
{
    std::string line;
    while (std::getline(in, line))
        text.push_back(line);
}
int main(int argc, char* argv[])
{
    // Part 1. Read the entire input into text. If the command line names a file,
    // read that file. Otherwise, read the standard input.
    std::vector<std::string> text; ///< Store the lines of text here
    if (argc < 2)
        read(std::cin, text);
    else
    {
        std::ifstream in(argv[1]);
//line 36
        if (not in)
        {
            std::perror(argv[1]);
            return EXIT_FAILURE;
        }
        read(in, text);
    }
    // Part 2. Sort the text.
    std::sort(text.begin(), text.end());
    // Part 3. Print the sorted text.
    std::copy(text.begin(), text.end(),
        std::ostream_iterator<std::string>(std::cout, "\n"));
} 
4

0 回答 0