Thanks jsmith. The problem is in the copy constructor. I just commented it and now the code works. Just to understand a little bit more, why the copy constructor defined as above is wrong?
You are declaring a variable myVec_ inside the function that shadows the class member myVec_.
The assignment is assigning to the local variable, not to the class member.
Syntactically it looks like you are simply creating a temporary object within the constructor which happens to have the same name as the class attribute. Since this is the constructor, you'd want to use the initializer list. When it is all said and done, the object that was constructed has an empty myVec_ object. Then you try to make a call to its operator() function will attempts to access an empty vector using its operator[] which causes undefined behavior. You can confirm this by setting breakpoints and stepping into the copy constructor and operator() functions (assuming that they weren't inlined by the compiler). Anyway, as jsmith indicates the copy constructor and assignment operator aren't necessary.
without incurring in a compilation error because of 2 can be interpreted as more than one type? I mean I would like this to compile independently if I use 2*x or 2.0*x