In C++, when I am using std::cout like that:
std::cout << "myString" << std::endl;
Is there anything that will be allocated on the heap by std::cout? Or will std::cout do everything on the stack (meaning that std::cout and its underlying functions won’t do any new/malloc/etc...)?
I want to know if heavily using std::cout could cause some heap fragmentation
In this specific example your code isn’t causing any direct allocations on the heap. However it’s possible for the implementation of any method to use the heap for part of it’s work. This is perfectly fine so long as the method implementation properly cleans up after itself.
This logic applies to methods such as
operator<<(std::ostream&, T).