|
Boost Users : |
From: Filip KonviÄka (filip.konvicka_at_[hidden])
Date: 2007-03-15 07:46:15
>> I've been playing with the problem too, and found this solution...it
>> does not rely on typeof, but it does rely on return_type. I'm a bit
>> unsure about why I had to use "unsigned int" to make it work, so I'd
>> welcome some comments on this.
>>
>
> Do you mean you couldn't use RetType properly? I've tried with
> the following in GCC 3.2:
>
> template<class T, typename MemberType, MemberType T::* MemberPtr,
> typename RetType, RetType (MemberType::*MemberFct)() const>
> struct extract_and_call {
> typedef RetType result_type;
> RetType operator()(T const& t) const {
> return ((t .* MemberPtr) .* MemberFct)();
> }
> };
>
Aye, I got the following warning that I could not get rid of (VC 7.1)
C:\Boost\include\boost-1_33_1\boost\functional\hash\hash.hpp(132) :
warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int',
possible loss of data
Complete error (warning) message:
C:\Boost\include\boost-1_33_1\boost\functional\hash\hash.hpp(132) :
error C2220: warning treated as error - no object file generated
C:\Boost\include\boost-1_33_1\boost\functional\hash\hash.hpp(130) :
while compiling class-template member function 'size_t
boost::hash_detail::call_hash<T>::call(const T &)'
with
[
T=extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>::result_type
]
C:\Boost\include\boost-1_33_1\boost\functional\hash\hash.hpp(315) : see
reference to class template instantiation
'boost::hash_detail::call_hash<T>' being compiled
with
[
T=extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>::result_type
]
C:\Boost\include\boost-1_33_1\boost\functional\hash\hash.hpp(314) :
while compiling class-template member function 'size_t
boost::hash<T>::operator ()(const T &) const'
with
[
T=extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>::result_type
]
C:\Boost\include\boost-1_33_1\boost\multi_index\hashed_index.hpp(980) :
see reference to class template instantiation 'boost::hash<T>' being
compiled
with
[
T=extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,st
d::char_traits<char>,std::allocator<char>>::size(void) const>::result_type
]
C:\Boost\include\boost-1_33_1\boost\multi_index_container.hpp(80) : see
reference to class template instantiation
'boost::multi_index::detail::hashed_index<KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>'
being compiled
with
[
KeyFromValue=boost::multi_index::hashed_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>::key_from_value_type,
Hash=boost::multi_index::hashed_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>::hash_type,
Pred=boost::multi_index::hashed_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>::pred_type,
SuperMeta=boost::multi_index::detail::nth_layer<1,foo,boost::multi_index::indexed_by<boost::multi_index::hashed_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>,boost::multi_index::ordered_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::siz
e_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>>,std::allocator<foo>>,
TagList=boost::multi_index::hashed_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>::tag_list_type,
Category=boost::multi_index::detail::hashed_unique_tag
]
LCS.cpp(94) : see reference to class template instantiation
'boost::multi_index::multi_index_container<Value,IndexSpecifierList>'
being compiled
with
[
Value=foo,
IndexSpecifierList=boost::multi_index::indexed_by<boost::multi_index::hashed_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>,boost::multi_index::ordered_unique<extract_and_call<foo,std::string,pointer-to-member(0x0),std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type,std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size_type
std::basic_string<char,std::char_traits<char>,std::allocator<char>>::size(void)
const>>>
]
C:\Boost\include\boost-1_33_1\boost\functional\hash\hash.hpp(132) :
warning C4267: 'argument' : conversion from 'size_t' to 'unsigned int',
possible loss of data
Cheers,
Filip
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