std::endl *is* a function.
When people are typing std::endl they are actually passing the pointer of the function to the 'operator <<' of class basic_ostream
__ostream_type&
operator<<(__ostream_type& (*__pf)(__ostream_type&))
The same is true for all other similar methods, like std::hex, std::oct, std::dec etc
So if you are going to special handle the 'endl' case, make sure you handle the other methods as well (hex, dec, oct etc.)
Eran