Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2003-09-15 00:57:26


At 06:46 2003-09-15, Eric Friedman wrote:
>Boosters,
>
>I posted some time ago about what seemed to be a bug in Metrowerks's
>CodeWarrior 8.3 compiler that was standing in the way of complete
>functionality of the upcoming Variant library (namely reference content for
>variants). I have not yet found a workaround, but I have more precisely
>identified the problem.
>
>The problem can be reproduced by attempting to compile the code shown below.
>Note that this code successfully compiles on at least the following
>compilers: MSVC 7.1, gcc 2.95 and up, Borland 5.51, and Comeau 4.3 and up.
>
>Any help would be greatly appreciated. Also, it might be worthwhile
>introducing a new defect macro to the config library.

How about this:

template<class T>
struct enable_if_nonconst
{
    typedef void* type;
};

template<class T>
struct enable_if_nonconst<const T> {};

   struct test_t
   {
       template <typename T>
       test_t(T&, typename enable_if_nonconst<T>::type p = 0)
       {
       }

       template <typename T>
       test_t(const T&)
       {
       }
   };

>Thanks,
>Eric
>---
>
> struct test_t
> {
> template <typename T>
> test_t(T&)
> {
> }
>
> template <typename T>
> test_t(const T&)
> {
> }
> };
>
> void test_impl(test_t)
> {
> }
>
> template <typename T>
> void test()
> {
> T t;
>
> T & x = t;
> test_impl(x);
>
> T const & cx = x;
> test_impl(cx); // CW8.3: compile error here
> }
>
> int main()
> {
> test< int >();
> return 0;
> }
>
>
>
>_______________________________________________
>Unsubscribe & other changes:
>http://lists.boost.org/mailman/listinfo.cgi/boost

---
Daniel Wallin

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