Commit 42e857bc authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Merge branch 'UB-constness' into 'master'

Remove const qualifier from object that can be modified

See merge request count0/graph-tool!27
parents 46993132 8ba30ef3
Pipeline #633 passed with stage
in 297 minutes and 28 seconds
...@@ -562,7 +562,7 @@ private: ...@@ -562,7 +562,7 @@ private:
value_type _default; value_type _default;
}; };
// the following is a property map which always returns a constant value // the following is a property map which always returns the same value
template <class Value, class Key> template <class Value, class Key>
class ConstantPropertyMap class ConstantPropertyMap
: public boost::put_get_helper<Value, ConstantPropertyMap<Value,Key>> : public boost::put_get_helper<Value, ConstantPropertyMap<Value,Key>>
...@@ -573,19 +573,20 @@ public: ...@@ -573,19 +573,20 @@ public:
typedef Key key_type; typedef Key key_type;
typedef boost::readable_property_map_tag category; typedef boost::readable_property_map_tag category;
ConstantPropertyMap(const value_type& c): c(c) {} ConstantPropertyMap(const value_type& c): _c(c) {}
ConstantPropertyMap(): c() {} ConstantPropertyMap(): _c() {}
ConstantPropertyMap(const ConstantPropertyMap& o): c(o.c) {} ConstantPropertyMap(const ConstantPropertyMap& o): _c(o._c) {}
const value_type& operator[](const key_type&) const { return c; } const value_type& operator[](const key_type&) const { return _c; }
ConstantPropertyMap& operator=(const ConstantPropertyMap& other) ConstantPropertyMap& operator=(const ConstantPropertyMap& other)
{ {
const_cast<value_type&>(c) = other.c; _c = other._c;
return *this; return *this;
} }
const value_type c; private:
value_type _c;
}; };
template <class Value, class Key> template <class Value, class Key>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment