501: Add stc_to_exact and stc_to_exact macros.

https://svn.lrde.epita.fr/svn/oln/trunk/static ChangeLog | 14 ++++++++++++++ stc/exact.hh | 8 ++++++-- stc/vtypes.hh | 2 +- tests/exact.cc | 14 ++++++++++++++ tests/find_exact.cc | 5 ++--- tests/vtypes-and-exact.cc | 10 +++++++--- 6 files changed, 44 insertions(+), 9 deletions(-) Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Add stc_to_exact and stc_to_exact_ macros. * stc/exact.hh (stc_to_exact, stc_to_exact_): New macros. * stc/vtypes.hh (type_of_): Use the stc_to_exact macro instead of stc::to_exact_. * tests/exact.cc (main): Perform additional static tests. * tests/find_exact.cc (main): Use the stc_to_exact_ macro instead of stc::to_exact_. * tests/vtypes-and-exact.cc (main): Likewise Check the super classes. (A): Use stc::any instead of stc::any__simple. Index: stc/exact.hh --- stc/exact.hh (révision 500) +++ stc/exact.hh (copie de travail) @@ -35,14 +35,18 @@ # include <mlc/bexpr.hh> +/// \def Get the exact type of \a T. +#define stc_to_exact(T) \ + typename stc_to_exact_(T) + +#define stc_to_exact_(T) \ + stc::to_exact_< T >::ret # define stc_internal_is_any(T) \ mlc::bexpr_< sizeof(internal::any_select(internal::makePtr< T >())) == \ sizeof(internal::yes_) > - - namespace stc { Index: stc/vtypes.hh --- stc/vtypes.hh (révision 500) +++ stc/vtypes.hh (copie de travail) @@ -528,7 +528,7 @@ struct type_of_ \ { \ /* Get the exact type of \a from_type. */ \ - typedef typename stc::to_exact_<from_type>::ret from_exact_type; \ + typedef stc_to_exact(from_type) from_exact_type; \ \ /* Look for the typedef in internal types. */ \ typedef typename \ Index: tests/exact.cc --- tests/exact.cc (révision 500) +++ tests/exact.cc (copie de travail) @@ -56,6 +56,20 @@ int main() { + // Ensure stc::is_any_ works properly. + mlc::assert_< stc::is_any_< abstraction<concrete> > >::check(); + mlc::assert_< stc::is_any_< sub_abstraction<concrete> > >::check(); + mlc::assert_< stc::is_any_< concrete > >::check(); + + // Check stc_to_exact. + mlc::assert_< + mlc_eq(stc_to_exact_(abstraction<concrete>), concrete) + >::check(); + + mlc::assert_< + mlc_eq(stc_to_exact_(sub_abstraction<concrete>), concrete) + >::check(); + //----------------------------------------- { Index: tests/find_exact.cc --- tests/find_exact.cc (révision 500) +++ tests/find_exact.cc (copie de travail) @@ -65,7 +65,6 @@ mlc::assert_< mlc_is_a_(C, A) >::check(); mlc::assert_< mlc_is_a_(C, B) >::check(); - mlc::assert_< mlc_eq(stc::to_exact_< A< B<> > >::ret, - B<stc::itself>) >::check(); - mlc::assert_< mlc_eq(stc::to_exact_< A<C> >::ret, C) >::check(); + mlc::assert_< mlc_eq( stc_to_exact_(A< B<> >), B<stc::itself> ) >::check(); + mlc::assert_< mlc_eq( stc_to_exact_(A<C>), C ) >::check(); } Index: tests/vtypes-and-exact.cc --- tests/vtypes-and-exact.cc (révision 500) +++ tests/vtypes-and-exact.cc (copie de travail) @@ -113,7 +113,7 @@ }; template <typename Exact> - struct A : public stc::any__simple<Exact> + struct A : public stc::any<Exact> { // Aliases. typedef my_type_of(A, foo) foo_type; @@ -224,9 +224,13 @@ using my::B; using my::C; + // Check super classes. + mlc::assert_<mlc_is_a_(C, A)>::check(); + mlc::assert_<mlc_is_a_(C, B)>::check(); + // Check exact types of A<C> and B<C>. - mlc::assert_<mlc_eq(stc::to_exact_< A<C> >::ret, C)>::check(); - mlc::assert_<mlc_eq(stc::to_exact_< B<C> >::ret, C)>::check(); + mlc::assert_<mlc_eq(stc_to_exact_(A<C>), C)>::check(); + mlc::assert_<mlc_eq(stc_to_exact_(B<C>), C)>::check(); // Check types associated to A<C>.
participants (1)
-
Roland Levillain