Note that the C++ standard libraries are set up so that they inline all the templated functions that they can sensibly inline, and no real function copies exist. So for instance, when you go to call std::vector<int>::begin()
, there is no such function. All its uses have been inlined.
That is why you are getting errors about "call to function... not present in target." There may be inlined copies of the function, but none we can actually call. As an example, if I build a little C++ program that makes a std::vector, and pushes some elements onto it and then iterates over them, and then do:
(lldb) image lookup -r -n begin
2 matches found in /private/tmp/vector:
Address: vector[0x0000000100000eaf] (vector.__TEXT.__text + 1071)
Summary: vector`main + 1071 [inlined] std::__1::vector<int, std::__1::allocator<int> >::begin() at vector.cpp:12
vector`main + 1071 at vector.cpp:12 Address: vector[0x0000000100000eaf] (vector.__TEXT.__text + 1071)
Summary: vector`main + 1071 [inlined] std::__1::vector<int, std::__1::allocator<int> >::begin() at vector.cpp:12
vector`main + 1071 at vector.cpp:12
So all the instances of the begin & end accessors for std::vector<int>
are inlined. And further down in the part that comes from the std c library itself:
12 matches found in /usr/lib/libc++.1.dylib:
Address: libc++.1.dylib[0x000000000003e4ec] (libc++.1.dylib.__TEXT.__text + 252188)
Summary: libc++.1.dylib`std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::begin() Address: libc++.1.dylib[0x000000000003e51c] (libc++.1.dylib.__TEXT.__text + 252236)
Summary: libc++.1.dylib`std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::begin() const Address: libc++.1.dylib[0x000000000003e574] (libc++.1.dylib.__TEXT.__text + 252324)
and a few more for basic_string, and that's all. So there aren't any real implementations that we can call. Then once we've only got a little bit of the real world of these std objects available to us, the world falls apart in other odd ways as you start to push on it.
lldb isn't currently smart enough to figure out how to reconstitute a templated function/method from the C++ standard library's header files. We don't have enough of the environment in which your code was originally compiled to do that task.
Note that this isn't really a problem with overloaded operators, it is more a problem with the way the std libraries are used by the compiler. Things should work better for your own classes, where at -O0 there isn't so much inlining.