template <class T>
struct PrintableTupleTypeCtor
{
enum RetType { Ret = false };
};
template <class T>
concept bool PrintableType = (bool)PrintableTupleTypeCtor<T>::Ret || requires(PrintBase &out,const T &t)
{
PrintAdapter<T>::Print(out,t);
} ;
template <PrintableType ... TT>
struct PrintableTupleTypeCtor<Tuple<TT...> >
{
enum RetType { Ret = true };
};
--
You received this message because you are subscribed to the Google Groups "SG8 - Concepts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concepts+u...@isocpp.org.
To post to this group, send email to conc...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/concepts/.
/* main.cpp */
#include <iostream>
using namespace std;
/* struct Fold<TT> */
template <class ... TT> struct Fold;
/* concept TestInt<T> */
template <class T>
struct IntFoldCtor
{
enum RetType { Ret = false };
};
template <class T>
concept bool TestInt = (bool)IntFoldCtor<T>::Ret || is_same<T,int>::value ;
template <TestInt ... TT>
struct IntFoldCtor<Fold<TT...> >
{
enum RetType { Ret = true };
};
/* main() */
int main()
{
cout << TestInt<int> << endl ; // 1
cout << TestInt<short> << endl ; // 0
cout << TestInt< Fold<int,int,int> > << endl ; // 1
cout << TestInt< Fold<int,int,short> > << endl ; // 0
cout << TestInt< Fold<int,Fold<int,int>,int> > << endl ; // 0
cout << TestInt< Fold<int,Fold<int,short>,int> > << endl ; // 0
cout << TestInt< Fold<int,Fold<int,int>,short> > << endl ; // 0
return 0;
}
Looks legal to me.Is it failing on a tuple of tuples?
--Andrew Sutton
template <class ... TT> struct Fold;
template <class>
constexpr bool IntFoldCtor = false;
template <>
constexpr bool IntFoldCtor<int> = true;
template <class T>
concept bool TestInt = IntFoldCtor<T>;
template <TestInt ... TT>
constexpr bool IntFoldCtor<Fold<TT...>> = true;
static_assert( TestInt<int>);
static_assert(!TestInt<short>);
static_assert( TestInt<Fold<int,int,int>>);
static_assert(!TestInt<Fold<int,int,short>>);
static_assert( TestInt<Fold<int,Fold<int,int>,int>>);
static_assert(!TestInt<Fold<int,Fold<int,short>,int>>);
static_assert(!TestInt<Fold<int,Fold<int,int>,short>>);
int main() {}