Hi,
I'm trying to use the boost::multi_index_container to index a struct based
on a enum and a std::string.
While I can retrive data from the container by search on the string any
attempts to such on the enum results in a compliation error.
Anyone got any ideas as to what I need todo to get this to work :)
The compiler is MSVC++7.1
Any Help would be appricated :)
Relivaent code and errors follow:
:
namespace mi = boost::multi_index;
struct FilterCreatorDetails
{
FilterCreatorDetails(FileTypes id, std::string key, filtercreator
creator) : id_(id), key_(key), creator_(creator)
{
}
FilterCreatorDetails(FilterCreatorDetails const &lhs) :
id_(lhs.id_), key_(lhs.key_), creator_(lhs.creator_)
{
}
std::string key_;
FileTypes id_;
filtercreator creator_;
bool operator<(FilterCreatorDetails const &lhs) const
{
return id_ < lhs.id_;
};
};
struct key{};
struct id{};
typedef mi::multi_index_container<
FilterCreatorDetails,
mi::indexed_by<
mi::ordered_unique< mi::tag<id> ,
mi::identity<FilterCreatorDetails> >, // orders by operator <
mi::ordered_non_unique >
>
> texmap_t;
// code below doesnt work, causes errors on compile when i try to use the
'find' function
filtercreator FilterRegister::getCreator(FileTypes val)
{
typedef texmap_t::index<id>::type tex_by_id;
tex_by_id::iterator it = texturefilters->get<id>().find(val);
return (*it).creator_;
return filtercreator();
}
// this function works however...
filtercreator FilterRegister::getCreator(std::string const &val)
{
typedef texmap_t::index<key>::type tex_by_name;
tex_by_name::iterator it = texturefilters->get<key>().find(val);
/*texmap_t::const_iterator val = texturefilters->find(key);*/
return (*it).creator_;
}
// The short errors :
g:\Boost\include\boost-1_33\boost\multi_index\detail\ord_index_ops.hpp(72):
error C2664: 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &)
const' : cannot convert parameter 1 from 'const
GameTextureLoader::FileTypes' to 'const
boost::multi_index::detail::non_const_identity_base<Type>::result_type &'
with
[
_Ty=boost::multi_index::detail::non_const_identity_baseGameTextureLoader::FilterCreatorDetails::result_type
]
and
[
Type=GameTextureLoader::FilterCreatorDetails
]
g:\Boost\include\boost-1_33\boost\multi_index\detail\ord_index_ops.hpp(65):
error C2664: 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &)
const' : cannot convert parameter 2 from 'const
GameTextureLoader::FileTypes' to 'const
boost::multi_index::detail::non_const_identity_base<Type>::result_type &'
with
[
_Ty=boost::multi_index::detail::non_const_identity_baseGameTextureLoader::FilterCreatorDetails::result_type
]
and
[
Type=GameTextureLoader::FilterCreatorDetails
]
// the long rambling build log errors
------ Build started: Project: Game Texture Loader, Configuration: Debug
Win32 ------
Compiling...
GTL_internal.cpp
g:\Boost\include\boost-1_33\boost\multi_index\detail\ord_index_ops.hpp(65) :
error C2664: 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &)
const' : cannot convert parameter 2 from 'const
GameTextureLoader::FileTypes' to 'const
boost::multi_index::detail::non_const_identity_base<Type>::result_type &'
with
[
_Ty=boost::multi_index::detail::non_const_identity_baseGameTextureLoader::FilterCreatorDetails::result_type
]
and
[
Type=GameTextureLoader::FilterCreatorDetails
]
Reason: cannot convert from 'const GameTextureLoader::FileTypes' to
'const
boost::multi_index::detail::non_const_identity_base<Type>::result_type'
with
[
Type=GameTextureLoader::FilterCreatorDetails
]
No constructor could take the source type, or constructor overload
resolution was ambiguous
g:\Boost\include\boost-1_33\boost\multi_index\ordered_index.hpp(383)
: see reference to function template instantiation 'Node
*boost::multi_index::detail::ordered_index_find::node_type,boost::multi_index::detail::ordered_index::key_from_value,CompatibleKey,boost::multi_index::detail::ordered_index::key_compare>(Node
*,const KeyFromValue &,const CompatibleKey &,const CompatibleCompare &)'
being compiled
with
[
Node=boost::multi_index::detail::ordered_indexGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::key_from_value_type,boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::compare_type,boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_byGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>,boost::multi_index::ordered_non_uniqueGameTextureLoader::key,boost::multi_index::memberGameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>,std::allocatorGameTextureLoader::FilterCreatorDetails>,boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::tag_list_type,boost::multi_index::detail::ordered_unique_tag>::node_type,
KeyFromValue=boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::key_from_value_type,
Compare=boost::multi_index::ordered_uniqueGameTextureLoader::FilterCreatorDetails>::compare_type,
SuperMeta=boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_byGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>,boost::multi_index::ordered_non_uniqueGameTextureLoader::key,boost::multi_index::memberGameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>,std::allocatorGameTextureLoader::FilterCreatorDetails>,
TagList=boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::tag_list_type,
Category=boost::multi_index::detail::ordered_unique_tag,
CompatibleKey=GameTextureLoader::FileTypes,
CompatibleCompare=boost::multi_index::detail::ordered_indexGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::key_from_value_type,boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::compare_type,boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_byGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>,boost::multi_index::ordered_non_uniqueGameTextureLoader::key,boost::multi_index::memberGameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>,std::allocatorGameTextureLoader::FilterCreatorDetails>,boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::tag_list_ty
pe,boost::multi_index::detail::ordered_unique_tag>::key_compare
]
d:\My Documents\Visual Studio Projects\Game Texture
Loader\GTL_internal.cpp(46) : see reference to function template
instantiation
'boost::multi_index::detail::ordered_index::iterator
boost::multi_index::detail::ordered_index::findGameTextureLoader::FileTypes(const
CompatibleKey &) const' being compiled
with
[
KeyFromValue=boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::key_from_value_type,
Compare=boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::compare_type,
SuperMeta=boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_byGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>,boost::multi_index::ordered_non_uniqueGameTextureLoader::key,boost::multi_index::memberGameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>,std::allocatorGameTextureLoader::FilterCreatorDetails>,
TagList=boost::multi_index::ordered_uniqueGameTextureLoader::id,boost::multi_index::identityGameTextureLoader::FilterCreatorDetails>::tag_list_type,
Category=boost::multi_index::detail::ordered_unique_tag,
CompatibleKey=GameTextureLoader::FileTypes
]
g:\Boost\include\boost-1_33\boost\multi_index\detail\ord_index_ops.hpp(72) :
error C2664: 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &)
const' : cannot convert parameter 1 from 'const
GameTextureLoader::FileTypes' to 'const
boost::multi_index::detail::non_const_identity_base<Type>::result_type &'
with
[
_Ty=boost::multi_index::detail::non_const_identity_baseGameTextureLoader::FilterCreatorDetails::result_type
]
and
[
Type=GameTextureLoader::FilterCreatorDetails
]
Reason: cannot convert from 'const GameTextureLoader::FileTypes' to
'const
boost::multi_index::detail::non_const_identity_base<Type>::result_type'
with
[
Type=GameTextureLoader::FilterCreatorDetails
]
No constructor could take the source type, or constructor overload
resolution was ambiguous
Build Time 0:07
Build log was saved at "file://d:\My Documents\Visual Studio Projects\Game
Texture Loader\Debug\BuildLog.htm"
Game Texture Loader - 2 error(s), 0 warning(s)
------ Build started: Project: GTLTester, Configuration: Debug Win32 ------
GTLTester - up-to-date.
Build Time 0:00
---------------------- Done ----------------------
Build: 1 succeeded, 1 failed, 0 skipped