Code:
#include <list>
#include <string>
using namespace std;
list<string> return_a_list();
int main() {
list<string> LS1;
LS1.push_back("element 1 from LS1");
LS1.push_back("element 2 from LS1");
LS1.push_back("element 3 from LS1");
LS1.push_back("element 4 from LS1");
// This works...
list<string> temp = return_a_list();
LS1.splice(LS1.end(), temp);
// ...then why can't I do this???
LS1.splice(LS1.end(), return_a_list());
}
list<string> return_a_list() {
list<string> return_list;
return_list.push_back("element 1 from return_a_list");
return_list.push_back("element 2 from return_a_list");
return return_list;
}
The compile error from
http://www.comeaucomputing.com/tryitout is, "no instance of overloaded function "list<string>::splice"".
Just a curiosity, but aren't 'return_a_list()' and 'temp' the same type?
Lyle.