QMCPACK
Scalar.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // ACL:license
3 // ----------------------------------------------------------------------
4 // This software and ancillary information (herein called "SOFTWARE")
5 // called PETE (Portable Expression Template Engine) is
6 // made available under the terms described here. The SOFTWARE has been
7 // approved for release with associated LA-CC Number LA-CC-99-5.
8 //
9 // Unless otherwise indicated, this SOFTWARE has been authored by an
10 // employee or employees of the University of California, operator of the
11 // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
12 // the U.S. Department of Energy. The U.S. Government has rights to use,
13 // reproduce, and distribute this SOFTWARE. The public may copy, distribute,
14 // prepare derivative works and publicly display this SOFTWARE without
15 // charge, provided that this Notice and any statement of authorship are
16 // reproduced on all copies. Neither the Government nor the University
17 // makes any warranty, express or implied, or assumes any liability or
18 // responsibility for the use of this SOFTWARE.
19 //
20 // If SOFTWARE is modified to produce derivative works, such modified
21 // SOFTWARE should be clearly marked, so as not to confuse it with the
22 // version available from LANL.
23 //
24 // For more information about PETE, send e-mail to pete@acl.lanl.gov,
25 // or visit the PETE web page at http://www.acl.lanl.gov/pete/.
26 // ----------------------------------------------------------------------
27 // ACL:license
28 
29 #ifndef PETE_PETE_SCALAR_H
30 #define PETE_PETE_SCALAR_H
31 
32 ///////////////////////////////////////////////////////////////////////////////
33 //
34 // WARNING: THIS FILE IS FOR INTERNAL PETE USE. DON'T INCLUDE IT YOURSELF
35 //
36 ///////////////////////////////////////////////////////////////////////////////
37 
38 //-----------------------------------------------------------------------------
39 //
40 // CLASS NAME
41 // Scalar<T>
42 //
43 // DESCRIPTION
44 // A wrapper around a scalar to be used in PETE expressions.
45 //
46 //-----------------------------------------------------------------------------
47 
48 template<class T>
49 class Scalar
50 {
51 public:
52  //---------------------------------------------------------------------------
53  // Default constructor takes no action.
54 
55  inline Scalar() {}
56 
57  //---------------------------------------------------------------------------
58  // Constructor from a single value.
59 
60  inline Scalar(const T& t) : scalar_m(t) {}
61 
62  template<class T1>
63  inline explicit Scalar(const T1& t) : scalar_m(t)
64  {}
65 
66  //---------------------------------------------------------------------------
67  // Constructor with arbitrary second/third arguments, which is/are ignored.
68  // Needed for compatibility with tree node constructors taking an
69  // arbitrary argument.
70 
71  template<class Arg>
72  inline Scalar(const Scalar<T>& s, const Arg&) : scalar_m(s.scalar_m)
73  {}
74 
75  template<class Arg1, class Arg2>
76  inline Scalar(const Scalar<T>& s, const Arg1&, const Arg2&) : scalar_m(s.scalar_m)
77  {}
78 
79  //---------------------------------------------------------------------------
80  // Copy constructor
81 
82  inline Scalar(const Scalar<T>& s) : scalar_m(s.scalar_m) {}
83 
84  //---------------------------------------------------------------------------
85  // Return value.
86 
87  inline const T& value() const { return scalar_m; }
88 
89  //---------------------------------------------------------------------------
90  // Assignment operators.
91 
92  inline Scalar<T>& operator=(const Scalar<T>& rhs)
93  {
94  scalar_m = rhs.scalar_m;
95  return *this;
96  }
97 
98  inline Scalar<T>& operator=(const T& rhs)
99  {
100  scalar_m = rhs;
101  return *this;
102  }
103 
104 private:
105  //---------------------------------------------------------------------------
106  // The scalar value is stored here.
107 
109 };
110 
111 
112 #endif // PETE_PETE_SCALAR_H
113 
114 // ACL:rcsinfo
Scalar()
Definition: Scalar.h:55
Definition: Scalar.h:49
T scalar_m
Definition: Scalar.h:108
Scalar< T > & operator=(const Scalar< T > &rhs)
Definition: Scalar.h:92
Scalar(const Scalar< T > &s, const Arg1 &, const Arg2 &)
Definition: Scalar.h:76
Scalar(const Scalar< T > &s)
Definition: Scalar.h:82
Scalar(const T &t)
Definition: Scalar.h:60
Scalar(const Scalar< T > &s, const Arg &)
Definition: Scalar.h:72
Scalar(const T1 &t)
Definition: Scalar.h:63
Scalar< T > & operator=(const T &rhs)
Definition: Scalar.h:98
const T & value() const
Definition: Scalar.h:87