次の方法で共有


引数依存 (Koenig) 検索のサポート

更新 : 2007 年 11 月

Visual C++ コンパイラで Koenig 検索が完全にサポートされるようになりました。

詳細については、「Argument Dependent Name (AKA Koenig) Lookup on Functions」を参照してください。

使用例

次のコード例は、Visual Studio .NET と Visual Studio .NET 2003 で実行時異なる動作をします。

// bc_argument_dependent_AKA_Koenig_lookup_now_supported.cpp
// compile with: /W1
#include <stdio.h>

namespace N {
   class X {};

   void f(X *pX) {
      printf_s("in N::X::f\n");
   };   // called if compiled with 7.1
}

void f(void *pv) {
   printf_s("in ::f\n");
};   // called if compiled with 7.0

int main() {
   N::X *pX = 0;
   f(pX);

   // The following lines will result in the same behavior
   // in Visual Studio .NET or Visual Studio .NET 2003
   f((void*)pX);   // Cast pX to void before calling f; calls global f
   ::f(pX);    // Explicitly specify global f
   N::f(pX);   // Explicitly specify f in namespace
}

in N::X::f
in ::f
in ::f
in N::X::f

参照

参照

Visual C++ コンパイラの互換性に影響する変更点