473,569 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::f oo_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::f oo_t());
#endif
}
Jul 22 '05 #1
1 1604
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::f oo_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::f oo_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
1688
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 flag_type {F1, F2, F3}; } void foo(Flags::flag_type f) {
2
1918
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. Is it me or the compiler? namespace Tangram { namespace Backend { struct RELATIONAL;
3
2910
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 reading about it on google, but there is something I still don't understand, and I'm hoping someone will be willing to explain it to me in small...
3
10620
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 that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays...
3
1216
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 flag_type {F1, F2, F3}; } void foo(Flags::flag_type f) {
5
2337
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 std::basic_ostream<charT, traits ... } and a manipulator
2
2034
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 with the syntax func<5>(); and for the dynamic version with
16
1641
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
2114
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 A has to be specified in the definition of Y. This makes Y unusable for any multiply_traits defined in other namespaces, which corresponding T1...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.