Which namespace does operator<< (stream) go to?

后端 未结 4 1008
慢半拍i
慢半拍i 2021-02-19 06:01

If I have have some overloaded ostream operators, defined for library local objects, is its okay for them to go to std namespace? If I do not declare them in std namespace, then

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-19 06:22

    According to Koenig Lookup (C++ Standard 3.4.2) operator<< will be searched in namespaces of arguments. No need to declare it in std namespace.

提交回复
热议问题