Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2003-09-13 12:53:36


I've found a curiously recurring bug during the testing of my recently
submitted indexed_set library, which btw I recommend
having a look at --ok, enough publicizing already :)

This bug has to do with the support of pointers to members as
non-type template parameters. It is officially confirmed to be
present in MSVC++ 6.0:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;249045

but later I found that Intel C++ 7.1 for Windows also have problems
in this area (though not exactly the same). For instance,
the following program

**BEGIN CODE
#include <utility>
#include <iostream>

using namespace std;

template<class Class,typename Type,Type Class::*PtrToMember>
struct member:std::unary_function<Class,Type>
{
const Type& operator()(const Class&x)const
{
return x.*PtrToMember;
}

Type& operator()(Class &x)const
{
return x.*PtrToMember;
}
};

typedef std::pair<int,int> pair_of_ints;

int main()
{
pair_of_ints p(0,1);
int i=member<pair_of_ints,int,&pair_of_ints::first>()(p);
int j=member<pair_of_ints,int,&pair_of_ints::second>()(p);

cout<<i<<","<<j<<endl;
return 0;
}

** END CODE**

outputs 1,1 instead of 0,0. Somehow, the compiler cannot
distinguish between the two instantiations of member<>.

Having into account that the bug spans across several compilers
(at least two), is this important enough to deserve a defect macro
in Boost.Config? If so, I can provide a test for it.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk