is it nonsense to use std::move like this?

closed account (oSGzwA7f)
1
2
3
4
5
6
7
8
std::string insert::simple_insert () const
{
    std::string start{"INSERT into "};
    std::string values{" VALUES (" };
    std::string list = return_list ();
    std::string end{");"};
    return std::move (start + table + values + list + end);
}
Yes, the return statement works (and by 'works' I mean decides what code to compile) in three stages:
1) if allowed, perform copy/move elision (unless optimizations are disabled)
2) otherwise, if possible, move
3) otherwise, if possible, copy
(otherwise, fail to compile)

you're asking it to do stage 2 only

some docs
http://en.cppreference.com/w/cpp/language/copy_elision
http://en.cppreference.com/w/cpp/language/return
Last edited on
Topic archived. No new replies allowed.