Use non-const string type in map.
Using const string as key type instead of plain string fails with libc++, the standard library implementation used by clang. The libc++ implementation assumes that map keys can be copied, and the standard requires map keys to be copyable. Using const string as a value also fails with clang, I am not 100% sure why. It does severely restrict how you can interact with the container, and seems to make it noncopyable. The error is reported from DynamicState<GroupTree>::update(), the std::fill() call.
This commit is contained in:
@@ -34,8 +34,8 @@ class GroupTree {
|
||||
bool exists( const std::string& group ) const;
|
||||
const std::string& parent( const std::string& name ) const;
|
||||
std::vector< std::string > children( const std::string& parent ) const;
|
||||
const std::map<const std::string , size_t>& nameSeqIndMap() const;
|
||||
const std::map<size_t, const std::string >& seqIndNameMap() const;
|
||||
const std::map<std::string , size_t>& nameSeqIndMap() const;
|
||||
const std::map<size_t, std::string >& seqIndNameMap() const;
|
||||
size_t groupTreeSize();
|
||||
bool operator==( const GroupTree& ) const;
|
||||
bool operator!=( const GroupTree& ) const;
|
||||
@@ -57,8 +57,8 @@ class GroupTree {
|
||||
std::vector< group > groups = { group { "FIELD", "" } };
|
||||
friend bool operator<( const std::string&, const group& );
|
||||
std::vector< group >::iterator find( const std::string& );
|
||||
std::map<const std::string , size_t> m_nameSeqIndMap;
|
||||
std::map<size_t, const std::string > m_seqIndNameMap;
|
||||
std::map<std::string , size_t> m_nameSeqIndMap;
|
||||
std::map<size_t, std::string > m_seqIndNameMap;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ void GroupTree::update( const std::string& name) {
|
||||
* and represented elsewhere)
|
||||
*/
|
||||
|
||||
const std::map<const std::string , size_t>& GroupTree::nameSeqIndMap() const {
|
||||
const std::map<std::string , size_t>& GroupTree::nameSeqIndMap() const {
|
||||
return m_nameSeqIndMap;
|
||||
}
|
||||
|
||||
const std::map<size_t, const std::string >& GroupTree::seqIndNameMap() const {
|
||||
const std::map<size_t, std::string >& GroupTree::seqIndNameMap() const {
|
||||
return m_seqIndNameMap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user