Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2003-09-17 08:00:49


John Maddock ha escrito:

> > 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.
>
> Looks like it: what do we call the macro? Do you want to supply the test
> program? (see Boost.config docs for the details),

Something like

BOOST_NO_POINTERS_TO_MEMBERS_AS_NON_TYPE_TEMPLATE_ARGUMENTS

(admittedly a little long, but cutting anything will lead to confusing
interpretations.)
Please find test code at the end of this mail. Checked to work for g++3.2 under
Cygwin and to fail (as it should) in MSVC ++6.5 and Intel C++ 7.1 for Windows.

>
>
> BTW, we normally wait for libraries to be accepted before committing new
> config macros for them (sometimes the need for the macro goes away during
> the review).
>

Well, strictly speaking indexed_set does not rely on detecting this bug.
It simply provides a replacement member_offset<> for member<>; it is up
to the user to decide which want she should use. Of course, having this
macro in Boost could simplify things, at least from the usability point
of view.

(off-topic: allow me to invite you to take a look at the library, your opinions
and suggestions will be most welcome)

Regards,

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

*** CODE FOR boost_no_ptrs_to_mem_as_non_type_temp_args.cxx
// (C) Copyright Joaquín M López Muñoz 2003. Permission to copy, use, modify,
// sell and distribute this software is granted provided this copyright notice
// appears in all copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any purpose.

// MACRO: BOOST_NO_POINTERS_TO_MEMBERS_AS_NON_TYPE_TEMPLATE_ARGUMENTS
// TITLE: pointers to members as non-type template arguments
// DESCRIPTION: Defective support for pointers to members as non-type template
arguments

namespace boost_no_pointers_to_members_as_non_type_template_arguments{

struct pair
{
  int x,y;

  pair(int x_,int y_):x(x_),y(y_){}
};

template<int pair::* PtrToPairMember>
struct foo
{
  int bar(pair& p){return p.*PtrToPairMember;}
};

int test()
{
  pair p(0,1);
  foo<&pair::x> fx;
  foo<&pair::y> fy;

  if(fx.bar(p)!=0||fy.bar(p)!=1)return -1;

  return 0;
}

}

*** END CODE


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