This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/39413] static_assert and SFINAE



------- Comment #2 from paolo dot carlini at oracle dot com  2009-03-09 18:10 -------
The below, not using any header neither C++0x mode (very likely can be further
reduced), doesn't compile with mainline and 4_3-branch, does with EDG-based
compilers in strict mode:

template<bool>
  class __static_assert { };

template<>
  class __static_assert<false>;

template<typename T, typename U>
  struct __are_same { static const bool value = false; };

template<typename T>
  struct __are_same<T, T> { static const bool value = true; };

    class A {

    };

    class B : public A {

    };

    class C {

    };

    namespace gc {

        template <typename T> class member_ptr;
    }

    template <typename T> class weak_ptr {

    public:

        weak_ptr() {}

        template <typename X> weak_ptr(const weak_ptr<X>& v) {}

        weak_ptr(const gc::member_ptr<T>& v);

        template <typename X> weak_ptr& operator=(const weak_ptr<X>& v) {
return *this; }
    };

    namespace gc {

        template <typename T> class member_ptr {

          __static_assert<__are_same<C, T>::value> sa;
       };
    }

int main() {

    weak_ptr<A> ap1;
    weak_ptr<B> bp1;

    ap1 = bp1;
}


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-03-09 18:10:02
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]