diff options
Diffstat (limited to 'deps/tao_tuple/28626e99/include/tao/seq/partial_sum.hpp')
-rw-r--r-- | deps/tao_tuple/28626e99/include/tao/seq/partial_sum.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/deps/tao_tuple/28626e99/include/tao/seq/partial_sum.hpp b/deps/tao_tuple/28626e99/include/tao/seq/partial_sum.hpp new file mode 100644 index 0000000000..b66a02d5f0 --- /dev/null +++ b/deps/tao_tuple/28626e99/include/tao/seq/partial_sum.hpp @@ -0,0 +1,42 @@ +// The Art of C++ / Sequences +// Copyright (c) 2015 Daniel Frey + +#ifndef TAOCPP_SEQUENCES_INCLUDE_PARTIAL_SUM_HPP +#define TAOCPP_SEQUENCES_INCLUDE_PARTIAL_SUM_HPP + +#include <cstddef> +#include <utility> + +#include "make_integer_sequence.hpp" +#include "sum.hpp" + +namespace tao +{ + namespace seq + { + namespace impl + { + template< std::size_t, typename S, typename = make_index_sequence< S::size() > > + struct partial_sum; + + template< std::size_t I, typename T, T... Ns, std::size_t... Is > + struct partial_sum< I, integer_sequence< T, Ns... >, index_sequence< Is... > > + : seq::sum< T, ( ( Is < I ) ? Ns : 0 )... > + { + static_assert( I <= sizeof...( Is ), "tao::seq::partial_sum<I, S>: I is out of range" ); + }; + } + + template< std::size_t I, typename T, T... Ns > + struct partial_sum + : impl::partial_sum< I, integer_sequence< T, Ns... > > + {}; + + template< std::size_t I, typename T, T... Ns > + struct partial_sum< I, integer_sequence< T, Ns... > > + : impl::partial_sum< I, integer_sequence< T, Ns... > > + {}; + } +} + +#endif // TAOCPP_SEQUENCES_INCLUDE_PARTIAL_SUM_HPP |