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