Closed Romain-Geissler-1A closed 1 year ago
Did you actually test this? When merge this change I get compile error:
`class helper_collection { helper_collection(const helper_collection&); // non-copyable helper_collection& operator = (const helper_collection&); // non-copyable
// note: we dont' actually "share" the function object pointer
// we only use shared_ptr to make sure that it get's deleted
typedef std::pair<
const void *,
boost::shared_ptr<void>
> helper_value_type;
template<class T>
boost::shared_ptr<void> make_helper_ptr(){
// use boost::shared_ptr rather than std::shared_ptr to maintain
// c++03 compatibility
return boost::make_shared<T>();
}
typedef std::vector<helper_value_type> collection;
collection m_collection;
struct predicate {
BOOST_DEFAULTED_FUNCTION(predicate(const predicate& rhs), { m_ti = rhs.m_ti; }) // Cannot assign to non-static data member 'm_ti' with const-qualified type 'const void *const'
BOOST_DELETED_FUNCTION(predicate & operator=(const predicate & rhs))
public:
const void * const m_ti; // Non-static data member 'm_ti' declared const here
bool operator()(helper_value_type const &rhs) const {
return m_ti == rhs.first;
}
predicate(const void * ti) :
m_ti(ti)
{}
};
protected:
helper_collection(){}
~helper_collection(){}
public:
template
void * rval = 0;
if(it == m_collection.end()){
m_collection.push_back(
std::make_pair(id, make_helper_ptr<Helper>())
);
rval = m_collection.back().second.get();
}
else{
rval = it->second.get();
}
return *static_cast<Helper *>(rval);
}
}; `
I am not at work right now, so I cannot check, but all patches we submit we usually apply it in our own code base. However it’s been a long time we don’t use C++03 anymore, so in our case what we test is the explicitly defaulted copy constructor. I actually expect the CI to detect these kind of things to prevent from merging too soon.
i guess here the fix is to initialize the member outside the body, but I don’t know if this is allowed by this boost macro. I can have a look on Friday when I am back to work.