Re: [sigc] TypeTraits



Hi Arnaud!

Thanks for reporting this! You are right, the instance() method is completely ununsed. It was needed for some early alpha versions of libsigc++2 that used gcc's non-portable typeof() keyword. I never thought of removing it.

The problem is: formally, the type_trait<> template is part of the public API so I hesitate to silently remove the instance() method. On the hand, it doesn't really make sense to conditionally generate it - our only alternative.

So, I'm asking the list: is there anybody against completely removing the (internally unused) type_trait<>::instance() method?

Regards,

 Martin


Am 28.07.2004 18:25:51 schrieb(en) Arnaud Debaene:
The following doesn't compile neither with VC 7.1 neither with Comeau
(but it's ok with GCC) :



class VirtualClass

{

public:

   virtual void f()=0;



   sigc::signal<void> event;

   void CallbackFunc()  {};



   void DoConnection()

   {

event.connect(sigc::mem_fun(this, &VirtualClass:: CallbackFunc));

   }

};



This is because of the implementation of type_traits :

truct type_trait

{

  typedef T_type  type;

  typedef T_type& pass;

  typedef const T_type& take;

  typedef T_type* pointer;

  static  T_type  instance(); /* not implemented */

};



When instanciating is_base_and_derived<trackable, VirtualClass>, the
compiler refuses to generate instance() because VirtualClass is
virtual.
However, the instance() method is never used in the code. I do not
know
m4, but it seems that this method is only used with GCC to circumvent
a
GCC bug / use the typeof facility : see operator.h.m4, line 91.
Therefore, I guess those type_trait::instance() methods should be
removed, or at least generated only conditionnally.



Here is the complete compiler error message with VC 7.1 :





d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++ \type_traits.h(
33) : error C2259: 'VirtualClass' : cannot instantiate abstract class

        due to following members:

        'void VirtualClass::f(void)' : pure virtual function was not
defined


d:\users\adb\dev\temp\test_libsigcplusplus_abstractclass \test_libsigcplu
splus_abstractclass\test_libsigcplusplus_abstractclass.cpp(12) : see
declaration of 'VirtualClass::f'


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++ \type_traits.h(
116) : see reference to class template instantiation
'sigc::type_trait<T_type>' being compiled

        with

        [

            T_type=VirtualClass

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\visit_each. h(7
2) : see reference to class template instantiation
'sigc::is_base_and_derived<T_base,T_derived>' being compiled

        with

        [

            T_base=sigc::trackable,

            T_derived=VirtualClass

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\visit_each. h(1
13) : see reference to function template instantiation 'void
sigc::internal::limit_derived_target<T_target,T_action>::operator
()<T_functor>(const T_type &) const' being compiled

        with

        [

            T_target=sigc::trackable *,

            T_action=sigc::internal::slot_do_bind,

            T_functor=VirtualClass,

            T_type=VirtualClass

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\functors \mem_f
un.h(1798) : see reference to function template instantiation 'void
sigc::visit_each<T_action,T_obj>(const T_action &,const T_functor &)'
being compiled

        with

        [


T_action=sigc::internal::limit_derived_target<sigc::trackable
*,sigc::internal::slot_do_bind>,

            T_obj=VirtualClass,

            T_functor=VirtualClass

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\adaptors \adapt
or_trait.h(267) : see reference to function template instantiation
'void
sigc::visit_each<T_action,void,VirtualClass>(const T_action &,const
sigc::bound_mem_functor0<T_return,T_obj> &)' being compiled

        with

        [

            T_action=sig

c::internal::limit_derived_target<sigc::trackable
*,sigc::internal::slot_do_bind>,

            T_return=void,

            T_obj=VirtualClass

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\visit_each. h(1
24) : see reference to function template instantiation 'void
sigc::visit_each<sigc::internal::limit_derived_target<T_target, T_action>
,sigc::adaptor_trait<T_functor>::functor_type>(const
sigc::internal::limit_derived_target<T_target,T_action> &,const
sigc::adaptor_functor<T_functor> &)' being compiled

        with

        [

            T_target=sigc::trackable *,

            T_action=sigc::internal::slot_do_bind,

            T_functor=sigc::bound_mem_functor0<void,VirtualClass>

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\functors \slot.
h(39) : see reference to function template instantiation 'void
sigc::visit_each_type<sigc::trackable*,sigc::internal::slot_do_bind, sigc
::internal::typed_slot_rep<T_functor>::adaptor_type>(const T_action
&,const sigc::adaptor_functor<T_functor> &)' being compiled

        with

        [

            T_functor=sigc::bound_mem_functor0<void,VirtualClass>,

            T_action=sigc::internal::slot_do_bind

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\functors \slot.
h(37) : while compiling class-template member function
'sigc::internal::typed_slot_rep<T_functor>::typed_slot_rep(const
T_functor &)'

        with

        [

            T_functor=sigc::bound_mem_functor0<void,VirtualClass>

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\functors \slot.
h(436) : see reference to class template instantiation
'sigc::internal::typed_slot_rep<T_functor>' being compiled

        with

        [

            T_functor=sigc::bound_mem_functor0<void,VirtualClass>

        ]


d:\users\adb\utils\libsigcplusplus\libsigc++-2.0.3\sigc++\functors \slot.
h(1089) : see reference to function template instantiation
'sigc::slot0<T_return>::slot0<T_functor>(const T_functor &)' being
compiled

        with

        [

            T_return=void,

            T_functor=sigc::bound_mem_functor0<void,VirtualClass>

        ]


d:\users\adb\dev\temp\test_libsigcplusplus_abstractclass \test_libsigcplu
splus_abstractclass\test_libsigcplusplus_abstractclass.cpp(19) : see
reference to function template instantiation
'sigc::slot<T_return>::slot<sigc::bound_mem_functor0<T_return,T_obj>> (co
nst T_functor &)' being compiled

        with

        [

            T_return=void,

            T_obj=VirtualClass,

            T_functor=sigc::bound_mem_functor0<void,VirtualClass>

        ]





Arnaud


_______________________________________________
libsigc-list mailing list
libsigc-list gnome org
http://mail.gnome.org/mailman/listinfo/libsigc-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]