rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.17k stars 439 forks source link

property_accessor.h : error: use of deleted function #305

Open ravindra181 opened 3 years ago

ravindra181 commented 3 years ago

I have a base class which has deleted function (=delete) for copy constructor and assignment operator. Also the derived classes are creating template type object.

Whenever I am registering as below, a compilation error is generated: registration::class_("acc::proxy::ACCProxy") .property("info", &ACCProxy::info) ( policy::prop::as_reference_wrapper );

Please help me to fix it so that I can do a successful registration.

==============Compile time error =================================== I am getting the following error: n file included from Rttr/include/rttr/detail/property/property_wrapper.h:39:0, from Rttr/include/rttr/detail/registration/registration_impl.h:38, from Rttr/include/rttr/registration.h:821, from cdcmaster/src/main.cpp:10: Rttr/include/rttr/detail/property/property_accessor.h: In instantiation of 'static bool rttr::detail::property_accessor::set_value(T&, const T&) [with T = ara::com::internal::proxy::Field]': Rttr/include/rttr/detail/property/property_wrapper_member_object.h:256:55: required from 'bool rttr::detail::property_wrapper<rttr::detail::member_object_ptr, A C::*, void, Acc_Level, rttr::detail::get_as_ref_wrapper, rttr::detail::set_as_ref_wrapper, Metadata_Count>::set_value(rttr::instance&, rttr::argument&) const [with C = vwg::services::acc::proxy::ACCProxy; A = ara::com::internal::proxy::Field; rttr::access_levels Acc_Level = (rttr::access_levels)0; long unsigned int Metadata_Count = 0]' cdcmaster/src/main.cpp:262:1: required from here Rttr/include/rttr/detail/property/property_accessor.h:48:13: error: use of deleted function 'ara::com::internal::proxy::Field& ara::com::internal::proxy::Field::operator=(const ara::com::internal::proxy::Field&) [with FieldTraits = vwg::services::acc::ACC::info]' prop = arg;


In file included from generated/vwg/services/acc/acc_proxy.h:18:0,
                 from cdcmaster/src/main.cpp:20:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ara/com/internal/proxy/field.hpp:60:12: note: declared here
     Field& operator=(const Field&) = delete;
            ^~~~~~~~
In file included from Rttr/include/rttr/variant.h:1156:0,
                 from Rttr/include/rttr/registration.h:38,
                 from cdcmaster/src/main.cpp:10:
Rttr/include/rttr/detail/variant/variant_impl.h: In instantiation of 'rttr::variant::variant(T&&) [with T = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>&; Tp = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>]':
Rttr/include/rttr/detail/property/property_wrapper_member_object.h:70:24:   required from 'rttr::variant rttr::detail::property_wrapper<rttr::detail::member_object_ptr, A C::*, void, Acc_Level, rttr::detail::return_as_copy, rttr::detail::set_value, Metadata_Count>::get_value(rttr::instance&) const [with C = vwg::services::acc::proxy::ACCProxy; A = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>; rttr::access_levels Acc_Level = (rttr::access_levels)0; long unsigned int Metadata_Count = 0]'
cdcmaster/src/main.cpp:262:1:   required from here
Rttr/include/rttr/detail/variant/variant_impl.h:61:5: error: static assertion failed: The given value is not copy constructible, try to add a copy constructor to the class.
     static_assert(std::is_copy_constructible<Tp>::value || std::is_array<Tp>::value,
     ^~~~~~~~~~~~~
In file included from Rttr/include/rttr/detail/variant/variant_impl.h:36:0,
                 from Rttr/include/rttr/variant.h:1156,
                 from Rttr/include/rttr/registration.h:38,
                 from cdcmaster/src/main.cpp:10:
Rttr/include/rttr/detail/variant/variant_data_policy.h: In instantiation of 'static void rttr::detail::variant_data_policy_big<T, Converter>::clone(const T&, rttr::detail::variant_data&) [with T = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>; Converter = rttr::detail::empty_type_converter<ara::com::internal::proxy::Field<vwg::services::acc::ACC::info> >; rttr::detail::variant_data = std::aligned_storage<8, 8>::type]':
Rttr/include/rttr/detail/variant/variant_data_policy.h:236:26:   required from 'static bool rttr::detail::variant_data_base_policy<T, Tp, Converter>::invoke(rttr::detail::variant_policy_operation, const variant_data&, rttr::detail::argument_wrapper) [with T = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>; Tp = rttr::detail::variant_data_policy_big<ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>, rttr::detail::empty_type_converter<ara::com::internal::proxy::Field<vwg::services::acc::ACC::info> > >; Converter = rttr::detail::empty_type_converter<ara::com::internal::proxy::Field<vwg::services::acc::ACC::info> >; rttr::detail::variant_data = std::aligned_storage<8, 8>::type]'
Rttr/include/rttr/detail/variant/variant_impl.h:59:14:   required from 'rttr::variant::variant(T&&) [with T = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>&; Tp = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>]'
Rttr/include/rttr/detail/property/property_wrapper_member_object.h:70:24:   required from 'rttr::variant rttr::detail::property_wrapper<rttr::detail::member_object_ptr, A C::*, void, Acc_Level, rttr::detail::return_as_copy, rttr::detail::set_value, Metadata_Count>::get_value(rttr::instance&) const [with C = vwg::services::acc::proxy::ACCProxy; A = ara::com::internal::proxy::Field<vwg::services::acc::ACC::info>; rttr::access_levels Acc_Level = (rttr::access_levels)0; long unsigned int Metadata_Count = 0]'
cdcmaster/src/main.cpp:262:1:   required from here
Rttr/include/rttr/detail/variant/variant_data_policy.h:459:39: error: use of deleted function 'ara::com::internal::proxy::Field<FieldTraits>::Field(const ara::com::internal::proxy::Field<FieldTraits>&) [with FieldTraits = vwg::services::acc::ACC::info]'
         reinterpret_cast<T*&>(dest) = new T(value);
                                       ^~~~~~~~~~~~
In file included from generated/vwg/services/acc/acc_proxy.h:18:0,
                 from cdcmaster/src/main.cpp:20:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ara/com/internal/proxy/field.hpp:59:5: note: declared here
     Field(const Field&) = delete;
     ^~~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/functional:58:0,
                 from cdcmaster/src/Subscriber.h:6,
                 from cdcmaster/src/testPublisher.h:3,
                 from cdcmaster/src/main.cpp:3:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/bits/std_function.h:685:7: error: 'std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::targetDistances::Notify]::<lambda()>; <template-parameter-2-2> = void; <template-parameter-2-3> = void; _Res = void; _ArgTypes = {}]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::targetDistances::Notify]::<lambda()>', is used but never defined [-fpermissive]
       function<_Res(_ArgTypes...)>::
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/types.hpp:28:0,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/defaults.hpp:13,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ara/com/types.h:12,
                 from generated/vwg/services/acc/acc_common.h:13,
                 from generated/vwg/services/acc/acc_proxy.h:16,
                 from cdcmaster/src/main.cpp:20:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/strand.hpp:130:10: error: 'void ac::com::Strand::post(F&&) [with F = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::targetDistances::Notify]::<lambda()>]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::targetDistances::Notify]::<lambda()>', is used but never defined [-fpermissive]
     void post(F&& task)
          ^~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/functional:58:0,
                 from cdcmaster/src/Subscriber.h:6,
                 from cdcmaster/src/testPublisher.h:3,
                 from cdcmaster/src/main.cpp:3:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/bits/std_function.h:685:7: error: 'std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::relevantObjects::Notify]::<lambda()>; <template-parameter-2-2> = void; <template-parameter-2-3> = void; _Res = void; _ArgTypes = {}]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::relevantObjects::Notify]::<lambda()>', is used but never defined [-fpermissive]
       function<_Res(_ArgTypes...)>::
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/types.hpp:28:0,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/defaults.hpp:13,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ara/com/types.h:12,
                 from generated/vwg/services/acc/acc_common.h:13,
                 from generated/vwg/services/acc/acc_proxy.h:16,
                 from cdcmaster/src/main.cpp:20:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/strand.hpp:130:10: error: 'void ac::com::Strand::post(F&&) [with F = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::relevantObjects::Notify]::<lambda()>]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::relevantObjects::Notify]::<lambda()>', is used but never defined [-fpermissive]
     void post(F&& task)
          ^~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/functional:58:0,
                 from cdcmaster/src/Subscriber.h:6,
                 from cdcmaster/src/testPublisher.h:3,
                 from cdcmaster/src/main.cpp:3:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/bits/std_function.h:685:7: error: 'std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::notifications::Notify]::<lambda()>; <template-parameter-2-2> = void; <template-parameter-2-3> = void; _Res = void; _ArgTypes = {}]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::notifications::Notify]::<lambda()>', is used but never defined [-fpermissive]
       function<_Res(_ArgTypes...)>::
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/types.hpp:28:0,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/defaults.hpp:13,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ara/com/types.h:12,
                 from generated/vwg/services/acc/acc_common.h:13,
                 from generated/vwg/services/acc/acc_proxy.h:16,
                 from cdcmaster/src/main.cpp:20:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/strand.hpp:130:10: error: 'void ac::com::Strand::post(F&&) [with F = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::notifications::Notify]::<lambda()>]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::notifications::Notify]::<lambda()>', is used but never defined [-fpermissive]
     void post(F&& task)
          ^~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/functional:58:0,
                 from cdcmaster/src/Subscriber.h:6,
                 from cdcmaster/src/testPublisher.h:3,
                 from cdcmaster/src/main.cpp:3:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/bits/std_function.h:685:7: error: 'std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::info::Notify]::<lambda()>; <template-parameter-2-2> = void; <template-parameter-2-3> = void; _Res = void; _ArgTypes = {}]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::info::Notify]::<lambda()>', is used but never defined [-fpermissive]
       function<_Res(_ArgTypes...)>::
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/types.hpp:28:0,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/defaults.hpp:13,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ara/com/types.h:12,
                 from generated/vwg/services/acc/acc_common.h:13,
                 from generated/vwg/services/acc/acc_proxy.h:16,
                 from cdcmaster/src/main.cpp:20:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/strand.hpp:130:10: error: 'void ac::com::Strand::post(F&&) [with F = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::info::Notify]::<lambda()>]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::info::Notify]::<lambda()>', is used but never defined [-fpermissive]
     void post(F&& task)
          ^~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/functional:58:0,
                 from cdcmaster/src/Subscriber.h:6,
                 from cdcmaster/src/testPublisher.h:3,
                 from cdcmaster/src/main.cpp:3:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/bits/std_function.h:685:7: error: 'std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::additionalInformation::Notify]::<lambda()>; <template-parameter-2-2> = void; <template-parameter-2-3> = void; _Res = void; _ArgTypes = {}]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::additionalInformation::Notify]::<lambda()>', is used but never defined [-fpermissive]
       function<_Res(_ArgTypes...)>::
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/types.hpp:28:0,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/cpp_binding/defaults.hpp:13,
                 from /opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ara/com/types.h:12,
                 from generated/vwg/services/acc/acc_common.h:13,
                 from generated/vwg/services/acc/acc_proxy.h:16,
                 from cdcmaster/src/main.cpp:20:
/opt/poky/2.4.4/sysroots/aarch64-poky-linux/usr/include/ac/com/strand.hpp:130:10: error: 'void ac::com::Strand::post(F&&) [with F = ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::additionalInformation::Notify]::<lambda()>]', declared using local type 'ac::com::cpp_binding::proxy::Event_impl<EventTraits>::on_subscription_state_change(ac::com::cpp_binding::Subscription_state)::<lambda()> [with EventTraits = vwg::services::acc::ACC::additionalInformation::Notify]::<lambda()>', is used but never defined [-fpermissive]
     void post(F&& task)
          ^~~~
===========================================
ravindra181 commented 3 years ago

Please someone can you help me to fix the error

ravindra181 commented 3 years ago

@iridinite : Can you please have a look at the problem My class is non copyable and non assignable but default moveable is enabled. The compilation error occurs when a property is registered. @acki-m can you please suggest what change is needed. I am trying to RTTR library into one of the biggest project for a large OEM