Bonmin  1.8.8
BonTypes.hpp
Go to the documentation of this file.
1 #ifndef __BonTypes_H_
2 #define __BonTypes_H_
3 #include<vector>
4 #include "CoinSmartPtr.hpp"
5 
6 namespace Bonmin {
8 template<typename T>
9 class vector : public std::vector<T>{
10 public:
12  vector(): std::vector<T>(){}
14  vector(size_t n, const T& v): std::vector<T>(n,v){}
16  vector(const vector<T>& other): std::vector<T>(other){}
18  vector(const std::vector<T>& other): std::vector<T>(other){}
20  vector(size_t n): std::vector<T>(n){}
22  vector<T>& operator=(const vector<T>& other){
23  std::vector<T>::operator=(other);
24  return (*this);}
26  vector<T>& operator=(const std::vector<T>& other){
27  return std::vector<T>::operator=(other);
28  return (*this);}
29 
31 inline T* operator()(){
32  return &(*std::vector<T>::begin());
33 }
35 inline const T* operator()() const {
36  return &(*std::vector<T>::begin());
37 }
38 };
39 
40 //structure to store an object of class X in a Coin::ReferencedObject
41 template<class X>
44  X object;
45 
46  const X& operator()() const{
47  return object;}
48 
49  X& operator()() {
50  return object;}
51 
52 };
53 //structure to store a pointer to an object of class X in a
54 // Coin::ReferencedObject
55 template<class X>
58  X * object;
59 
61  object(NULL){}
62 
64  delete object;}
65 
66  const X& operator()() const{
67  return *object;}
68 
69  X& operator()() {
70  return *object;}
71 
72  const X* ptr() const{
73  return object;}
74 
75  X* ptr(){
76  return object;}
77 };
78 
79 template <class X>
82  ret_val->object = other;
83  return ret_val;
84 }
85 template <class X>
88  ret_val->object = other;
89  return ret_val;
90 }
91 
92 
93 }
94 #endif
95 
A small wrap around std::vector to give easy access to array for interfacing with fortran code.
Definition: BonTypes.hpp:9
vector(size_t n, const T &v)
Constructor with initialization.
Definition: BonTypes.hpp:14
T * operator()()
Access pointer to first element of storage.
Definition: BonTypes.hpp:31
vector()
Default constructor.
Definition: BonTypes.hpp:12
vector(const vector< T > &other)
Copy constructor.
Definition: BonTypes.hpp:16
const T * operator()() const
Access pointer to first element of storage.
Definition: BonTypes.hpp:35
vector(size_t n)
constructor with size.
Definition: BonTypes.hpp:20
vector< T > & operator=(const vector< T > &other)
Assignment.
Definition: BonTypes.hpp:22
vector< T > & operator=(const std::vector< T > &other)
Assignment.
Definition: BonTypes.hpp:26
vector(const std::vector< T > &other)
Copy constructor.
Definition: BonTypes.hpp:18
(C) Copyright International Business Machines Corporation 2007
SimpleReferenced< X > * make_referenced(X other)
Definition: BonTypes.hpp:80
const X * ptr() const
Definition: BonTypes.hpp:72
const X & operator()() const
Definition: BonTypes.hpp:66
const X & operator()() const
Definition: BonTypes.hpp:46