Pointer assignment

I have the following template structure:

template <typename scalar_type>
struct postc_params{
    scalar_type delta; 
    unsigned int time_horizon; 
    matrix_math::matrix<scalar_type> dynamics;
    boost::shared_ptr<continuous_set> invariant_set_ptr;
    boost::shared_ptr<continuous_set> input_set_ptr;
    boost::shared_ptr<continuous_set> initial_set_ptr;
};

Now I have a template template with a private member of the specified structure type

template <typename scalar_type>
class A{
....
private:
....
postc_params<scalar_type> my_postc;
};

Inside the definition of a member function of class A, I have the following line of code:

my_postc.initial_set_ptr = my_postc.initial_set_ptr->transform(some_obj);

The conversion function returns a type pointer

boost::shared_ptr<continuous_set>

With this code, I have the following error:

passing 'const boost :: shared_ptr' as the argument 'this' to the argument' boost :: shared_ptr <> & amp; raise :: shared_ptr <> :: operator = (const boost :: shared_ptr &) [with Y = const continuous :: continuous_set, T = continuous :: continuous_set] 'discards qualifiers

Can anyone help me with this?

+3
source share
2 answers

- const?

, - const, . const -, mutable.

,

mutable postc_params<scalar_type> my_postc;

. , , , my_postc, const. const, my_postc.

+1

const : "" const boost:: shared_ptr " 'this'"

-, , , const, ,

, mutable .

+1

Source: https://habr.com/ru/post/1726538/


All Articles