Created
July 25, 2015 16:52
-
-
Save krysseltillada/5078ea451418df3fbf4f to your computer and use it in GitHub Desktop.
std::forward_list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <forward_list> | |
void add_str (std::forward_list <std::string> flst, std::string str1 = "", std::string str2 = "") { | |
if (!str1.empty()) { | |
flst.insert_after (flst.before_begin(), str2); | |
flst.insert_after (flst.before_begin(), str1); | |
} else { | |
flst.insert_after (flst.before_begin(), str2); | |
} | |
for (auto i : flst) | |
std::cout << i << " "; | |
} | |
int main () | |
{ | |
std::forward_list <std::string> f1; | |
add_str (f1, "world"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment