|
Boost Users : |
From: Phantom (rob_at_[hidden])
Date: 2005-08-29 12:59:10
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 <mi::tag<key> ,
mi::member<FilterCreatorDetails,std::string, &FilterCreatorDetails::key_> >
>
> 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_base<GameTextureLoader::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_base<GameTextureLoader::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_base<GameTextureLoader::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<boost::multi_index::detail::ordered_index<KeyFromValue,Compare,SuperMeta,TagList,Category>::node_type,boost::multi_index::detail::ordered_index<KeyFromValue,Compare,SuperMeta,TagList,Category>::key_from_value,CompatibleKey,boost::multi_index::detail::ordered_index<KeyFromValue,Compare,SuperMeta,TagList,Category>::key_compare>(Node
*,const KeyFromValue &,const CompatibleKey &,const CompatibleCompare &)'
being compiled
with
[
Node=boost::multi_index::detail::ordered_index<boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::key_from_value_type,boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::compare_type,boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<GameTextureLoader::key>,boost::multi_index::member<GameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>>,std::allocator<GameTextureLoader::FilterCreatorDetails>>,boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity
<GameTextureLoader::FilterCreatorDetails>>::tag_list_type,boost::multi_index::detail::ordered_unique_tag>::node_type,
KeyFromValue=boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::key_from_value_type,
Compare=boost::multi_index::ordered_unique<boost::multi_index::tag<Ga
meTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::compare_type,
SuperMeta=boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<GameTextureLoader::key>,boost::multi_index::member<GameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>>,std::allocator<GameTextureLoader::FilterCreatorDetails>>,
TagList=boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::tag_list_type,
Category=boost::multi_index::detail::ordered_unique_tag,
CompatibleKey=GameTextureLoader::FileTypes,
CompatibleCompare=boost::multi_index::detail::ordered_index<boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::key_from_value_type,boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::compare_type,boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<GameTextureLoader::key>,boost::multi_index::member<GameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>>,std::allocator<GameTextureLoader::FilterCreatorDetails>>,boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_in
dex::identity<GameTextureLoader::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<KeyFromValue,Compare,SuperMeta,TagList,Category>::iterator
boost::multi_index::detail::ordered_index<KeyFromValue,Compare,SuperMeta,TagList,Category>::find<GameTextureLoader::FileTypes>(const
CompatibleKey &) const' being compiled
with
[
KeyFromValue=boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::key_from_value_type,
Compare=boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>::compare_type,
SuperMeta=boost::multi_index::detail::nth_layer<1,GameTextureLoader::FilterCreatorDetails,boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::FilterCreatorDetails>>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<GameTextureLoader::key>,boost::multi_index::member<GameTextureLoader::FilterCreatorDetails,std::string,pointer-to-member(0x0)>>>,std::allocator<GameTextureLoader::FilterCreatorDetails>>,
TagList=boost::multi_index::ordered_unique<boost::multi_index::tag<GameTextureLoader::id>,boost::multi_index::identity<GameTextureLoader::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_base<GameTextureLoader::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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net