[ConceptGCC] for Douglas Gregor

Hi Doulas, I sent this privately but have a feeling it may have got sopammed out. If you got it, apologies for abusing the boost list. Hi Douglas, Here is a sample test, but IMO the concept in main should fail, else it is not possible to replace a traits class, hence I have had to use one in the following: regards Andy Little //-----------------------------//line1 //defines result types for binary ops and for static types with no runtime functions #include <quan/meta/binary_operation.hpp> namespace quan {namespace meta{ // is a type mpl::void_? // (binary_operation returns mpl::void for invalid ops, hence the need to query ) namespace detail{ auto concept NotMplVoid<typename T> { typename type = T; }; concept_map NotMplVoid<boost::mpl::void_> { typedef void type; }; } auto concept IsNotMplVoid< typename T> { where std::SameType<detail::NotMplVoid<T>::type,T>; }; auto concept OperatorPlus<typename T1, typename T2>{ typename type = binary_operation<T1, plus, T2>::type; where IsNotMplVoid<type>; }; // should I need to do this ?... see below template <typename T1, typename T2> where OperatorPlus<T1,T2> struct operator_plus{ typedef OperatorPlus<T1,T2>::type type; }; }} #include <quan/meta/rational.hpp> int main() { using quan::meta::rational; // succeeds but shouldnt AFAICS // as this is invalid op and type is mpl::void_ here typedef quan::meta::OperatorPlus<rational<1>,int >::type res; // line 45 // fails as expected but why does the Concept version above succeed? typedef quan::meta::operator_plus<rational<1>,int >::type res; // line 49 } ConceptGCC output: concept_test.cpp: In function 'int main()': concept_test.cpp:49: error: template arguments for 'struct quan::meta::operator_plus<quan::meta::rational<1, 1>, int>' do not meet the requirements of the primary template concept_test.cpp:49: note: no concept map for requirement 'quan::meta::OperatorPlus<quan::meta::rational<1, 1>, int>' concept_test.cpp:49: error: 'type' in class 'quan::meta::operator_plus<quan::meta::rational<1, 1>, int>' does not name a type ConceptGCC --version: conceptg++ (GCC) 4.1.1 (Indiana University ConceptGCC alpha 3) Copyright (C) 2006 Free Software Foundation, Inc. Copyright (C) 2005, 2006 Trustees of Indiana University. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. regards Andy Little
participants (1)
-
Andy Little