#11488 closed Bugs (invalid)
flat_map and value_type
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | To Be Determined | Component: | container |
Version: | Boost 1.57.0 | Severity: | Problem |
Keywords: | Cc: |
Description
There is a problem with the value_type typedef. It is a typedef of std::pair<Key, Value> but shouldn't it be std::pair<const Key, Value>?
typedef boost::unordered_map<int, string> Int2StringUmap; typedef boost::container::flat_map<int, string> Int2StringFmap;
static_assert(std::is_same<Int2StringUmap::value_type, std::pair<const int, string>>::value, ""); ok static_assert(std::is_same<Int2StringFmap::value_type, std::pair<const int, string>>::value, ""); not ok
Maybe already reported, but I couldn't find it in the svn.
Change History (2)
comment:1 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 6 years ago
Ok I have to work around this then, e.g. the following code will not compile when fed with a flat_map const_iterator:
template <typename Iterator> struct key_iterator : public boost::bidirectional_iterator_helper<key_iterator<Iterator>, typename std::iterator_traits<Iterator>::value_type::first_type> { typedef typename base::value_type value_type; value_type& operator* () const { return m_it->first; } private: Iterator m_it; };
Reviewing old bugs.
value_type is pair<Key,Value> as the internal type must be move constructible. This design is used since the pre-boost Loki AssocVector associative container.