
I see the vault contains some introspection helpers (for checking for member function existence). AFAICT these utilities are not currently in boost nor scheduled for review. Are there any plans to bring them forward? (There appears to be an overlap with some of the introspection utils in mpl - though only for member variables there.)

Richard Hazlewood wrote:
I see the vault contains some introspection helpers (for checking for member function existence). AFAICT these utilities are not currently in boost nor scheduled for review. Are there any plans to bring them forward?
I wish but there is still a substantial amoutn of work on them to make them work properly on MSVC. Unfortunately I have neither time nor proper knowledge of MSVC internal to make it in a reasonable amount of time. If anyone want to lend a hand, it'll be much appreciated. When this blockers are removed, then, yeah, some review may be asked. But i'm not sure we need to clutter boost with yet another MP namespace. They may fit nicely into type_traits.
(There appears to be an overlap with some of the introspection utils in mpl - though only for member variables there.)
Overlaps with ? MPL has check for inner type existence that's all no ? Anyway, this can be fixed easily ;) -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

joel <joel.falcou <at> lri.fr> writes:
Richard Hazlewood wrote:
I see the vault contains some introspection helpers (for checking for
member
I wish but there is still a substantial amoutn of work on them to make them work properly on MSVC.
I'm currently tied to MSVC7.1, and they appear to work okay with that. Is there a problem with a particular version? I've actually been looking for a way to check for: does (or, perhaps can) template function exist in type. I've been experimenting with modifying your macro, so that the signature becomes a template argument. E.g. so code such as: template <typename R, typename X> void foo() { bool const has = has_non_const_member_function_bar<X, R (*)()>::value; ... } struct X { template <typename T> T bar(); }; foo<int, X>(); Could be made to work. Trying: 1] #define BOOST_HAS_NON_CONST_MEMBER_FUNCTION(Name,Sig) \ 2] namespace boost \ 3] { \ 4] namespace introspection \ 5] { \ 6] template<class T, class F = Sig> \ 7] struct BOOST_PP_CAT(has_non_const_member_function_,Name) \ 8] { \ 9] typedef char NotFound; \ A] struct Found { char x[2]; }; \ B] \ C] template< typename build_member_type<T,F>::type \ D] > struct member {}; \ E] \ F] template<class X> static Found test(member<&X::Name>*); \ G] template<class X> static NotFound test( ... ); \ H] \ I] static const bool value = (sizeof(Found) == sizeof(test<T>(0))); \ J] typedef mpl::bool_<value> type; \ K] }; \ L] } \ M] } \ /**/ However, it doesn't appear to work (at least in VC71). It looks like the sizeof trick is not capable of stamping out the template function. Do you know if this can be achieved? Note: Lines [C-D, F] were modified from: template< class X \ , typename build_const_member_type<X,F>::type \ > struct member {}; template<class X> static Found test(X, member<&X::Name>*); \ Because VC71 would not compile it that way when Sig was a template arg (F). [shrug]. This didn't seem to affect the original behaviour, was there a reason for it?
(There appears to be an overlap with some of the introspection utils in mpl - Overlaps with ? MPL has check for inner type existence that's all no ?
Yes, 'overlap' was a poor choice of word; I probably meant association, but, as you say, it's closer to type_traits. Regards...

Thansk for the head up. I had report of MSVC8 failing to make sense out of them. Well, I'll have a short time span next month and i'll try to get a VM running with MSVC and hammer this out. Thanks for your interest :) -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

On Wed, Jul 22, 2009 at 6:21 AM, joel<joel.falcou@lri.fr> wrote:
Thansk for the head up. I had report of MSVC8 failing to make sense out of them. Well, I'll have a short time span next month and i'll try to get a VM running with MSVC and hammer this out. Thanks for your interest :)
For MS, you probably need to use the compiler specific extensions '__if_exists' etc __if_exists(Class::Mem) { static const bool value = true; } __if_not_exists(Class::Mem) { static const bool value = false; } Tony

Richard Hazlewood wrote:
I've actually been looking for a way to check for: does (or, perhaps can) template function exist in type.
I've been experimenting with modifying your macro, so that the signature becomes a template argument. E.g. so code such as:
template <typename R, typename X> void foo() { bool const has = has_non_const_member_function_bar<X, R (*)()>::value; ... }
struct X { template <typename T> T bar(); };
foo<int, X>();
Could be made to work.
Trying:
1] #define BOOST_HAS_NON_CONST_MEMBER_FUNCTION(Name,Sig) \ 2] namespace boost \ 3] { \ 4] namespace introspection \ 5] { \ 6] template<class T, class F = Sig> \ 7] struct BOOST_PP_CAT(has_non_const_member_function_,Name) \ 8] { \ 9] typedef char NotFound; \ A] struct Found { char x[2]; }; \ B] \ C] template< typename build_member_type<T,F>::type \ D] > struct member {}; \ E] \ F] template<class X> static Found test(member<&X::Name>*); \ G] template<class X> static NotFound test( ... ); \ H] \ I] static const bool value = (sizeof(Found) == sizeof(test<T>(0))); \ J] typedef mpl::bool_<value> type; \ K] }; \ L] } \ M] } \ /**/
However, it doesn't appear to work (at least in VC71). It looks like the sizeof trick is not capable of stamping out the template function.
Do you know if this can be achieved?
Note: Lines [C-D, F] were modified from:
template< class X \ , typename build_const_member_type<X,F>::type \ > struct member {};
template<class X> static Found test(X, member<&X::Name>*); \
Because VC71 would not compile it that way when Sig was a template arg (F). [shrug].
This didn't seem to affect the original behaviour, was there a reason for it?
I've been able to get a has_mem_fn-type trait to work on MSVC 8 and 9 by using the technique in the Adobe Move library's class_has_move_assign, http://stlab.adobe.com/move_8hpp_source.html Your lines [C-F] would look slightly different, roughly like template< typename signature< T0, ..., TN >::type > struct sfinae { typedef yes_type type; }; template< class U > static typename sfinae< &U:: name >::type test(int); template< class U > static no_type test(...); I don't know if this is any better for MSVC 7, though, but you can try :/ - Jeff
participants (5)
-
Gottlob Frege
-
Jeffrey Hellrung
-
joel
-
Mathias Gaunard
-
Richard Hazlewood