English 中文(简体)
Koenig 食堂
原标题:Rationale for Koenig lookup
  • 时间:2011-01-05 09:35:47
  •  标签:
  • c++

Koenig研究的理由是什么?

不能避免这样认为,使你的法典难以阅读和读取intable

他们能否界定“Koenig”调查,以便它只处理具体案件(例如:非成员经营人)或明确要求?

最佳回答

最初的动机,国际排雷中心,是能够书写

std::cout << 42;

without having to qualify std::operator<<(std::ostream&, int) explicitely.

如果你想提出令人难以置信的争辩,那么你可以明确限定职能名称,即。 使用<代码>std:swap,而不是swap,以防止swap<>/code>,在任何名称空间研究其论点。

也可以与SFINAE一道,在汇编某一类功能时测试某些功能(请你做这项工作,在Stackoverflow至少存在一个问题)。

问题回答

英国广播公司使用最强的案例就是这种情况。

namespace A
{
    struct S {};
    S operator+( const S&, const S& );
}

namespace B
{
    A::S test()
    {
        A::S a, b;
        return a + b;
    }
}

选择通用代码中的正确的<代码>swap功能也是有益的,因此该功能只应适用于operator的功能。 它已经是标准的一个相当复杂的部分,使某些情况下无法开展工作的规则会进一步复杂,会有什么好处?

我可以想到,要求明确提出这种要求,比直接在一个不同的名称空间中要求一项职能少得多,而且无论如何使表达更加复杂。

我们再思考一下:return [[使用_adl] (a + b); vsreturn A:operator+(a, b );?





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签