Koenig lookup - off by default?

Koenig lookup - off by default?

Firstly, can anyone confirm/dispute my finding that Koenig (Argument-dependent) lookup is off by default.

Consider the following code:

namespace koenig_lookup_ns
{
struct S
{};

static void f(S &);

void f(S &)
{}
}

void koenig_lookup_fn()
{
koenig_lookup_ns::S s;

f(s);
}

this does not compile, unless
-Qoption,cpp,--arg_dep_lookup
is specified.

(I'm talking about the Win32 version of these compilers.)

Second, is there another (easier) way of achieving this?

Third, is there a resource that specifies the available options that can be specified via -Qoption?

Fourth, and most importantly, is there a pre-processor symbol defined when Koenig lookup is defined (or when it's not)?

Thanks *very* much for any information

Matthew Wilson

STLSoft moderator and C++ monomaniac

mailto:matthew@stlsoft.org
http://www.stlsoft.org
news://news.digitalmars.com/c++.stlsoft

"If i'm curt with you it's because time is a factor. I think fast, I talk fast, and I need you guys to act fast" -- Mr Wolf

-------------------------------------------------------------------------------

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

In latest ICL 7.1 version (WCC_PC_7.1.018) Koenig lookup is on by default (at least in -Qvc7.1 mode, I didn't test other ones). But I don't know any preprocessor symbol describing this lookup state.

Unfortunately, I tried that, discriminating for __INTEL_COMPILER and _MSC_VER == 1310, but that still fails (e.g. on the test code in the first post).

That was from within VC6.0, with -Qvc7.1. I've not yet tried Intel C++ 7.1 from the command-line, or from within VS.NET, so maybe that's how you have it working. If it does perform differently between the two environments, then we can probably assume that there's more required than -Qvc7.1 (although I admit that wouldn't make too much sense, since -Qvc7.1 says "make me compatible with VC7.1)).

Puzzled, but unbeaten ...

Cheers

Matthew

Leave a Comment

Please sign in to add a comment. Not a member? Join today