473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Koenig lookup problem???

#include <iostream>

using std::cout;
using std::endl;

// #define CAUSE_ERROR

namespace N
{
struct foo_t {};
void foo_func(foo_t) {cout << "Got here!" << endl;}
}

int main()
{
#ifdef CAUSE_ERROR
// EXPECTED ERROR - the parentheses surrounding the function name inhibit
// argument-dependent (Koenig) lookup, so the identifier foo_func will
not
// be found.
(foo_func)(N::foo_t());
#else
foo_func(N::foo_t()); // This call should and does compile fine.

// Here, the same call that generates an error above works fine. I would
// have expected an error here due to the suppression of Koenig lookup
(as
// above). Is this behavior Standard-compliant, or have I indeed found a
bug
// in my implementation (VC++ 7.1)???
(foo_func)(N::foo_t());
#endif
}
Jul 22 '05 #1
1 1589
On Mon, 1 Dec 2003 20:23:01 -0700, "Dave" <be***********@yahoo.com>
wrote:
#include <iostream>

using std::cout;
using std::endl;

// #define CAUSE_ERROR

namespace N
{
struct foo_t {};
void foo_func(foo_t) {cout << "Got here!" << endl;}
}

int main()
{
#ifdef CAUSE_ERROR
// EXPECTED ERROR - the parentheses surrounding the function name inhibit
// argument-dependent (Koenig) lookup, so the identifier foo_func will
not
// be found.
(foo_func)(N::foo_t());
#else
foo_func(N::foo_t()); // This call should and does compile fine.

// Here, the same call that generates an error above works fine. I would
// have expected an error here due to the suppression of Koenig lookup
(as
// above). Is this behavior Standard-compliant, or have I indeed found a
bug
// in my implementation (VC++ 7.1)???
(foo_func)(N::foo_t());


Looks like a bug - your analysis is correct. VC seems to be thinking
that the use of N::foo_func adds an implicit using N::foo_func;
declaration.

Tom

C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: REH | last post by:
I'm a little confused about argument dependent lookup. Exactly when does this apply? Specifically, I was hoping to use it to access enumeration constants. For example: namespace Flags { enum...
2
by: Jean-Louis Leroy | last post by:
I'm trying to compile the following code with gcc (version below). I would expect the compile to try the operator ==() declared in Tangram::Backend because of Koenig lookup. But it doesn't happen....
3
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
3
by: REH | last post by:
I'm a little confused about argument dependent lookup. Exactly when does this apply? Specifically, I was hoping to use it to access enumeration constants. For example: namespace Flags { enum...
5
by: Javier Estrada | last post by:
I'm using a user-defined diagnostics stream and custom manipulators that work with it template<class charT, class traits = std::char_traits<charT> class basic_diagsstream : public...
2
by: cgv | last post by:
Hi, I want to distinguish between an int parameter to a template function depending on whether its value is known at compile time or not. For the compile time version I want to call the function...
16
by: Juha Nieminen | last post by:
The so-called koenig lookup allows doing odd things like this: #include <algorithm> #include <string> int main() { std::string table; sort(table, table+10); }
2
by: Peng Yu | last post by:
Hi, I'm wondering if Koenig lookup can be applied somehow to derive which template to use based on the template arguments. The following code shows an example where multiply_traits's namespace...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.