[英]using declaration for concrete output operator (with concrete signature)
namespace nm
{
class C1 {};
class C2 {};
inline std::ostream& operator << (std::ostream& lhs, std::vector<C1> const&) { return lhs; }
inline std::ostream& operator << (std::ostream& lhs, std::vector<C2> const&) { return lhs; }
}
using nm::operator<<;
Is there way to declare to use only one of operators <<
from namespace nm
in the global one, and not both? 有没有办法声明在全局名称空间nm
中仅使用名称空间nm
中的operators <<
,而不是全部使用?
One solution would be to put each operator<<
in its own nested name space: 一种解决方案是将每个operator<<
放在其自己的嵌套名称空间中:
namespace nm
{
class C1 {};
class C2 {};
namespace nm1 {
inline std::ostream& operator << (std::ostream& lhs, C1 const&) { return lhs; }
}
namespace nm2 {
inline std::ostream& operator << (std::ostream& lhs, C2 const&) { return lhs; }
}
}
using nm::nm1::operator<<;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.