Mirror reflection library 0.5.13

mirror/meta_prog/only_if.hpp

Go to the documentation of this file.
00001 
00012 #ifndef MIRROR_META_PROG_ONLY_IF_1011291729_HPP
00013 #define MIRROR_META_PROG_ONLY_IF_1011291729_HPP
00014 
00015 
00016 #include <mirror/meta_prog/range.hpp>
00017 #include <mirror/meta_prog/if.hpp>
00018 #include <mirror/meta_prog/prepend.hpp>
00019 #include <mirror/meta_prog/lambda.hpp>
00020 
00021 MIRROR_NAMESPACE_BEGIN
00022 namespace mp {
00023 
00024 #ifdef MIRROR_DOCUMENTATION_ONLY
00025 
00026 
00032 template <class Range, class Predicate>
00033 struct only_if
00034 {
00035     typedef Range type;
00036 };
00037 #endif
00038 
00039 // specialization for empty ranges
00040 template <class Predicate>
00041 struct only_if<range<>, Predicate>
00042 {
00043     typedef range<> type;
00044 };
00045 
00046 // specialization for ranges
00047 template <typename T, typename ... P, class Predicate>
00048 struct only_if<range<T, P...>, Predicate>
00049 {
00050     typedef typename if_<
00051         typename apply<Predicate, T>::type,
00052         typename prepend<T, only_if<range<P...>, Predicate> >::type,
00053         typename only_if<range<P...>, Predicate>::type
00054     >::type type;
00055 };
00056 
00057 // specialization for range expressions
00058 template <typename X, class Predicate>
00059 struct only_if
00060 {
00061     MIRROR_ASSERT_RETURNS_RANGE(X);
00062     typedef typename only_if<typename X::type, Predicate>::type type;
00063 };
00064 
00065 } // namespace mp
00066 MIRROR_NAMESPACE_END
00067 
00068 #endif //include guard
00069 

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.