I'm in the process at looking at issues related to that, but the thing to understand is that the object you create has to be boxed up for use inside of ChaiScript, in a
A few things:
- Can you verify what version of ChaiScript you are using? I see "only" 2 copy constructions happening when I execute this code.
- Because the value has to be boxed up, supplying a move constructor can help a lot.
See this code:
std::cout << "Def Const\n";
Test(const Test& t)
std::cout << "Copy Const\n";
std::cout << "Move constructed\n";
std::cout << "Dest\n";
Which gives me:
This not ideal, but much better. I'll be sure to put your example on my to-do list. It might explain some of the performance related issues I've been looking at lately. But make sure you provide a move constructor or do:
Test(Test &&) = default;
Because you provided a custom destructor in your code, you prevented the compiler from generating a move constructor for you.