LIBINT  2.1.0-stable
traits.h
1 /*
2  * This file is a part of Libint.
3  * Copyright (C) 2004-2014 Edward F. Valeev
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see http://www.gnu.org/licenses/.
17  *
18  */
19 
20 #include <bfset.h>
21 #include <smart_ptr.h>
22 #include <global_macros.h>
23 
24 #ifndef _libint2_src_bin_libint_traits_h_
25 #define _libint2_src_bin_libint_traits_h_
26 
27 namespace libint2 {
28 
29  template <typename T>
30  struct StorageTraits {
31  typedef SafePtr<T> StorageType;
32  enum { StoredAsPtr = true };
33  static const T& const_ref(const StorageType& s) { return *s; };
34  };
35 
36 #if USE_BRAKET_H
37  template <>
39  typedef CGShell StorageType;
40  enum { StoredAsPtr = false };
41  static const CGShell& const_ref(const StorageType& s) { return s; };
42  };
43 
44  template <>
45  struct StorageTraits<CGF> {
46  typedef CGF StorageType;
47  enum { StoredAsPtr = false };
48  static const CGF& const_ref(const StorageType& s) { return s; };
49  };
50 
51  template <CartesianAxis Axis>
52  struct StorageTraits< CGShell1d<Axis> > {
54  enum { StoredAsPtr = false };
55  static const CGShell1d<Axis>& const_ref(const StorageType& s) { return s; };
56  };
57 
58  template <CartesianAxis Axis>
59  struct StorageTraits< CGF1d<Axis> > {
60  typedef CGF1d<Axis> StorageType;
61  enum { StoredAsPtr = false };
62  static const CGF1d<Axis>& const_ref(const StorageType& s) { return s; };
63  };
64 #endif
65 
67 
69  template <typename Ref, typename Base>
71  typedef const Base& result;
72  };
73  template <typename Ref, typename Base>
74  struct ReturnTypeAnalog< SafePtr<Ref>, Base> {
75  typedef SafePtr<Base> result;
76  };
77 
79 
80  template <typename T>
81  struct TypeTraits {
83  typedef typename StorageTraits<T>::StorageType StorageType;
85  enum { StoredAsPtr = StorageTraits<T>::StoredAsPtr};
87  static const T& const_ref(const StorageType& s) { return StorageTraits<T>::const_ref(s); }
88  };
89 };
90 
91 #endif
92 
StorageTraits< T >::StorageType StorageType
By default, use SafePtr to manage these objects.
Definition: traits.h:83
Cartesian components of 3D CGF = 1D CGF.
Definition: bfset.h:425
3D Cartesian Gaussian Shell
Definition: bfset.h:231
Converts Base to a type of the same signature as Ref. For example, if Ref is SafePtr<T> then Base is ...
Definition: traits.h:70
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:23
a "shell" of 1D CGFs with quantum number L is a set of 1D CGFs with quantum numbers 0 ...
Definition: bfset.h:614
Definition: traits.h:30
Definition: traits.h:81
static const T & const_ref(const StorageType &s)
Convert an object of StorageType to const T&.
Definition: traits.h:87
3D Cartesian Gaussian Function
Definition: bfset.h:320