diff options
Diffstat (limited to 'src/input/detail/typeList.h')
-rw-r--r-- | src/input/detail/typeList.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/input/detail/typeList.h b/src/input/detail/typeList.h new file mode 100644 index 0000000..5b915a9 --- /dev/null +++ b/src/input/detail/typeList.h @@ -0,0 +1,76 @@ +/* + # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg + # + # This program is free software distributed under the GPL version 2. + # See http://openslx.org/COPYING + # + # If you have any feedback please consult http://openslx.org/feedback and + # send your suggestions, praise, or complaints to feedback@openslx.org + # + # General information about OpenSLX can be found at http://openslx.org/ + # -------------------------------------------------------------------------- + # detail/typeList.h: + # - Compile-time metaprogramming facilities: Type Lists and Member Check + # -------------------------------------------------------------------------- + */ + +#ifndef TYPELIST_H_ +#define TYPELIST_H_ + +namespace input_policy +{ +namespace detail +{ + +///////////////////////////////////////////////////////////////////////// +// TypeList, Contains, EmptyList: +// This class is autogenerated by gen/gen_typeList.cpp +///////////////////////////////////////////////////////////////////////// +#include "typeList_autogen.h" + +///////////////////////////////////////////////////////////////////////// +// Type-level functions that do not need to be autogenerated as they +// do not depend on the maximum number of entries: +// +// ForAnyInTypeList<Predicate, List>::value == true +// if there is any entry E in List for which +// Predicate::apply<E>::value == true +///////////////////////////////////////////////////////////////////////// +template<typename Predicate, typename List> +struct ForAnyInTypeList +{ + static const bool value = + Predicate::template apply<typename List::head>::value || + ForAnyInTypeList<Predicate, typename List::tail>::value; +}; + +template<typename Predicate> +struct ForAnyInTypeList<Predicate, EmptyList> +{ + static const bool value = false; +}; + +///////////////////////////////////////////////////////////////////////// +// ForAllInTypeList<Predicate, List>::value == true +// if there is not any entry E in List for which +// Predicate::apply<E>::value == false +///////////////////////////////////////////////////////////////////////// +template<typename Predicate, typename List> +struct ForAllInTypeList +{ + static const bool value = + Predicate::template apply<typename List::head>::value && + ForAllInTypeList<Predicate, typename List::tail>::value; +}; + +template<typename Predicate> +struct ForAllInTypeList<Predicate, EmptyList> +{ + static const bool value = true; +}; + +} + +} + +#endif /* TYPELIST_H_ */ |