-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
See
Lines 27 to 50 in cea1931
| __attribute__((pure)) std::string iotest::test4() { | |
| std::cout << "what is your name?"s << '\n'; | |
| std::string s2 = []() -> std::string { | |
| std::string s; | |
| std::getline(std::cin, s); | |
| return s; | |
| }(); | |
| std::cout << "hello "s + s2 << '\n'; | |
| return "I read the name "s + s2 + " from the command line!"s; | |
| } | |
| __attribute__((pure)) void iotest::test5() { | |
| std::string s = []() -> std::string { | |
| std::ifstream file("file.txt"s); | |
| if (!file) { | |
| std::cerr << "Failed to open file " << "file.txt"s << '\n'; | |
| return std::string{}; | |
| } | |
| return std::string(std::istreambuf_iterator<char>(file), | |
| std::istreambuf_iterator<char>()); | |
| }(); | |
| std::cout << s << '\n'; | |
| return; | |
| } |
These functions should not have __attribute__((pure)), as they have side effects.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels