示例#1
0
 static bool is_empty_function(F const& f) noexcept
 {
     using is_pointer = std::integral_constant<bool,
         std::is_pointer<F>::value
      || std::is_member_pointer<F>::value
     >;
     return is_empty_function(is_pointer{}, f);
 }
示例#2
0
 static bool is_empty_function(F const& f) noexcept
 {
     std::integral_constant<bool,
         std::is_pointer<F>::value
      || std::is_member_pointer<F>::value
     > is_pointer;
     return is_empty_function(f, is_pointer);
 }
示例#3
0
        void assign(F&& f)
        {
            if (!is_empty_function(f))
            {
                typedef typename util::decay<F>::type target_type;

                VTablePtr const* f_vptr = get_table_ptr<target_type>();
                if (vptr == f_vptr)
                {
                    vtable::reconstruct<target_type>(&object, std::forward<F>(f));
                } else {
                    reset();
                    vtable::destruct<empty_function<Sig> >(&this->object);

                    vptr = f_vptr;
                    vtable::construct<target_type>(&object, std::forward<F>(f));
                }
            } else {
                reset();
            }
        }
示例#4
0
        void assign(F&& f)
        {
            if (!is_empty_function(f))
            {
                typedef typename std::decay<F>::type target_type;

                VTable const* f_vptr = get_vtable<target_type>();
                if (vptr == f_vptr)
                {
                    vtable::reconstruct<target_type>(object, std::forward<F>(f));
                } else {
                    reset();
                    vtable::_delete<empty_function<R(Ts...)> >(object);

                    vptr = f_vptr;
                    vtable::construct<target_type>(object, std::forward<F>(f));
                }
            } else {
                reset();
            }
        }