Consider the code below:
#include <string>
#include <iostream>
int main()
{
std::string v = "abc";
auto func = [v] () // mutable makes v move
{
static_assert(!std::is_const_v<decltype(v)>);
static_assert(std::is_same_v<decltype(v), std::string>);
//it does not move
auto a = std::move(v);
std::cout << "v: " << v;
};
func();
return 0;
}
the output:
v: abc
Why v
does not move?
As far, as I can guess, without mutable
keyword something should be const-qualified. Where is this const
?