template concept question

I was reading about boosts concepts and I thought. Can I ask inside a template function if a member exists on a parameter of the function. For example. template <typename T> void func(T in) { exists(in, foo); } Where the "exists" line would return true if "in" had a member "foo" otherwise false.

AMDG Alan Tennant wrote:
I was reading about boosts concepts and I thought.
Can I ask inside a template function if a member exists on a parameter of the function.
For example.
template <typename T> void func(T in) { exists(in, foo); }
Where the "exists" line would return true if "in" had a member "foo" otherwise false.
There's an introspection library in the sandbox that does this, I think. http://svn.boost.org/svn/boost/sandbox/introspection In Christ, Steven Watanabe

Can I ask inside a template function if a member exists on a parameter of the function.
For example.
template <typename T> void func(T in) { exists(in, foo); }
Where the "exists" line would return true if "in" had a member "foo" otherwise false.
Note, however, that "introspection" libarary cannot detect an inherited member. If you use MSVC and don't need a portable code, you can use __if_exists statement: http://msdn.microsoft.com/en-us/library/x7wy9xh3(VS.80).aspx

I presume introspection is more portable.
I'm getting the error in forward1.hpp "cannot open include file:
'boost/introspection/detail/object_call_spec.hpp'". This file does not
appear to be on the sandbox.
On 9 March 2010 13:29, Igor R
Can I ask inside a template function if a member exists on a parameter of the function.
For example.
template <typename T> void func(T in) { exists(in, foo); }
Where the "exists" line would return true if "in" had a member "foo" otherwise false.
Note, however, that "introspection" libarary cannot detect an inherited member. If you use MSVC and don't need a portable code, you can use __if_exists statement: http://msdn.microsoft.com/en-us/library/x7wy9xh3(VS.80).aspx _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

I'm getting the error in forward1.hpp "cannot open include file: 'boost/introspection/detail/object_call_spec.hpp'". This file does not appear to be on the sandbox.
I use the version available here: http://www.boostpro.com/vault/ It compiles well.

Igor R wrote:
I use the version available here: http://www.boostpro.com/vault/ It compiles well. The sandbox introspection has nothign to do with my introspection in the vault, beware ;)
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

I use the version available here: http://www.boostpro.com/vault/ It compiles well.
The sandbox introspection has nothign to do with my introspection in the vault, beware ;)
Which one is better?

Igor R wrote:
Which one is better Well this is a non question. Mine solve compile-time introspection, the other seems to be runtime oriented.
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

Does your one do the same thing?
On 10 March 2010 18:24, Igor R
I use the version available here: http://www.boostpro.com/vault/ It compiles well.
The sandbox introspection has nothign to do with my introspection in the vault, beware ;)
Which one is better? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Alan Tennant
-
Igor R
-
joel falcou
-
Steven Watanabe