MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
tie.hpp
1#ifndef MPQC_RANGE_TIE_HPP
2#define MPQC_RANGE_TIE_HPP
3
4#include <boost/array.hpp>
5#include <boost/tuple/tuple.hpp>
6#include <boost/tuple/tuple_io.hpp>
7
8#include "mpqc/range.hpp"
9
10namespace mpqc {
11
14 template<class Tuple>
15 struct range::tie : Tuple {
16 static const int N = boost::tuples::length<Tuple>::value;
17 tie(const Tuple &s) : Tuple(s) {}
19 operator boost::array<range,N>() const {
20 boost::array<range,N> a;
21 cast(a, int_<N>());
22 return a;
23 }
25 operator std::vector<range>() const {
26 boost::array<range,N> a = *this;
27 return std::vector<range>(a.begin(), a.end());
28 }
29 private:
30 template<int I>
31 struct int_ {};
32 template<class V, int I>
33 void cast(V &v, int_<I>) const {
34 v[I-1] = range_cast(boost::tuples::get<I-1>(*this));
35 //std::cout << "cast " << I-1 << "=" << v[I-1] << std::endl;
36 cast(v, int_<I-1>());
37 }
38 template<class V>
39 void cast(V &v, int_<0>) const {}
40 };
41
42 template<class Tuple>
43 std::ostream& operator<<(std::ostream& os, const range::tie<Tuple> &tie) {
44 os << (const Tuple&)tie;
45 return os;
46 }
47
48}
49
50
51namespace mpqc {
52namespace detail {
53
54 // wrap boost::tuple T in range::tie
55 template<class T>
56 range::tie<T> range_tie(const T &t) {
57 return range::tie<T>(t);
58 }
59
60}
61}
62
63#endif // MPQC_RANGE_TIE_HPP
void operator<<(Array< T > A, const V &v)
Write to Array from a generic vector V.
Definition array.hpp:191
range range_cast(const range &r)
Cast range to range, return argument unchanged.
Definition range.hpp:123
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
boost::tuple tie wrapper
Definition tie.hpp:15

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.