summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim King <taking@google.com>2016-11-09 14:09:25 -0800
committerTim King <taking@google.com>2016-11-09 14:09:25 -0800
commit831f2b7176bc3db49e2fb354918a71df896ad63a (patch)
tree3cef485dbe92e5b0d200d314e844545de1714692 /src
parent8d0c4c7e8eb6c65facf87ad3b2e27f407096836c (diff)
Renaming the class PtrCloser to not cause confusion with unique_ptr.
Diffstat (limited to 'src')
-rw-r--r--src/base/Makefile.am4
-rw-r--r--src/base/ptr_closer.h (renamed from src/base/cvc4_unique_ptr.h)35
-rw-r--r--src/expr/metakind_template.h2
-rw-r--r--src/main/driver_unified.cpp8
4 files changed, 26 insertions, 23 deletions
diff --git a/src/base/Makefile.am b/src/base/Makefile.am
index 94e45c542..bf919cd81 100644
--- a/src/base/Makefile.am
+++ b/src/base/Makefile.am
@@ -20,14 +20,14 @@ libbase_la_SOURCES = \
configuration_private.h \
cvc4_assert.cpp \
cvc4_assert.h \
- cvc4_unique_ptr.h \
exception.cpp \
exception.h \
listener.cpp \
listener.h \
modal_exception.h \
output.cpp \
- output.h
+ output.h \
+ ptr_closer.h
diff --git a/src/base/cvc4_unique_ptr.h b/src/base/ptr_closer.h
index 9642d0185..9c40eee4b 100644
--- a/src/base/cvc4_unique_ptr.h
+++ b/src/base/ptr_closer.h
@@ -1,5 +1,5 @@
/********************* */
-/*! \file cvc4_unique_ptr.h
+/*! \file ptr_closer.h
** \verbatim
** Top contributors (to current version):
** Tim King
@@ -9,20 +9,22 @@
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
- ** \brief A CVC4 variant of unique_ptr for C++05.
+ ** \brief A class to close owned pointers in the destructor.
**
- ** A CVC4 variant of unique_ptr for C++05.
+ ** A class to close owned pointers in the destructor.
**/
#include "cvc4_public.h"
-#ifndef __CVC4__UNIQUE_PTR_H
-#define __CVC4__UNIQUE_PTR_H
+#ifndef __CVC4__PTR_CLOSER_H
+#define __CVC4__PTR_CLOSER_H
namespace CVC4 {
/**
- * A CVC4 variant of unique_ptr for C++05.
+ * A class to close owned pointers in the destructor. This plays a similar role
+ * to unique_ptr, but without move semantics. This is designed to overcome the
+ * lack of having unique_ptr in C++05.
*
* This is a variant of unique_ptr that is not designed for move semantics.
* These are appropriate to own pointer allocations on the stack that should be
@@ -30,13 +32,14 @@ namespace CVC4 {
* heap based data structures, and never as the return value of a function.
*/
template <class T>
-class UniquePtr {
+class PtrCloser {
public:
- UniquePtr() : d_pointer(NULL) {}
- UniquePtr(T* pointer) : d_pointer(pointer) {}
- ~UniquePtr() { delete d_pointer; }
+ PtrCloser() : d_pointer(NULL) {}
+ explicit PtrCloser(T* pointer) : d_pointer(pointer) {}
+ ~PtrCloser() { delete d_pointer; }
- void reset(T* pointer) {
+ /** Deletes the currently owned copy and takes ownership of pointer. */
+ void reset(T* pointer = NULL) {
delete d_pointer;
d_pointer = pointer;
}
@@ -58,13 +61,13 @@ class UniquePtr {
operator bool() const { return d_pointer != NULL; }
private:
- UniquePtr(const UniquePtr*) CVC4_UNDEFINED;
- UniquePtr& operator=(const UniquePtr&) CVC4_UNDEFINED;
+ PtrCloser(const PtrCloser*) CVC4_UNDEFINED;
+ PtrCloser& operator=(const PtrCloser&) CVC4_UNDEFINED;
- /** An owned pointer object allocated by `new` or NULL. */
+ /** An owned pointer object allocated by `new`. Or NULL. */
T* d_pointer;
-}; /* class UniquePtr */
+}; /* class PtrCloser */
} /* CVC4 namespace */
-#endif /* __CVC4__UNIQUE_PTR_H */
+#endif /* __CVC4__PTR_CLOSER_H */
diff --git a/src/expr/metakind_template.h b/src/expr/metakind_template.h
index 75521e901..1c03cf407 100644
--- a/src/expr/metakind_template.h
+++ b/src/expr/metakind_template.h
@@ -338,7 +338,7 @@ ${metakind_operatorKinds}
}/* CVC4::kind namespace */
-#line 341 "${template}"
+#line 342 "${template}"
namespace theory {
diff --git a/src/main/driver_unified.cpp b/src/main/driver_unified.cpp
index e9e703b5f..e43c8a6ee 100644
--- a/src/main/driver_unified.cpp
+++ b/src/main/driver_unified.cpp
@@ -26,8 +26,8 @@
#include "cvc4autoconfig.h"
#include "base/configuration.h"
-#include "base/cvc4_unique_ptr.h"
#include "base/output.h"
+#include "base/ptr_closer.h"
#include "expr/expr_iomanip.h"
#include "expr/expr_manager.h"
#include "main/command_executor.h"
@@ -242,7 +242,7 @@ int runCvc4(int argc, char* argv[], Options& opts) {
}
# endif
- UniquePtr<Parser> replayParser;
+ PtrCloser<Parser> replayParser;
if( opts.getReplayInputFilename() != "" ) {
std::string replayFilename = opts.getReplayInputFilename();
ParserBuilder replayParserBuilder(exprMgr, replayFilename, opts);
@@ -348,7 +348,7 @@ int runCvc4(int argc, char* argv[], Options& opts) {
vector< vector<Command*> > allCommands;
allCommands.push_back(vector<Command*>());
- UniquePtr<Parser> parser(parserBuilder.build());
+ PtrCloser<Parser> parser(parserBuilder.build());
if(replayParser) {
// have the replay parser use the file's declarations
replayParser->useDeclarationsFrom(parser.get());
@@ -503,7 +503,7 @@ int runCvc4(int argc, char* argv[], Options& opts) {
#endif /* CVC4_COMPETITION_MODE && !CVC4_SMTCOMP_APPLICATION_TRACK */
}
- UniquePtr<Parser> parser(parserBuilder.build());
+ PtrCloser<Parser> parser(parserBuilder.build());
if(replayParser) {
// have the replay parser use the file's declarations
replayParser->useDeclarationsFrom(parser.get());
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback