Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision 4e7c0fc0090de26380183bc8742b335bbe1cf243)
+++ libcfa/src/Makefile.am	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
@@ -41,5 +41,6 @@
 headers_nosrc = bitmanip.hfa exception.hfa math.hfa gmp.hfa time_t.hfa clock.hfa \
 		bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa containers/list.hfa containers/stackLockFree.hfa
-headers = common.hfa fstream.hfa heap.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa stdlib.hfa \
+headers = common.hfa fstream.hfa heap.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa \
+		time.hfa stdlib.hfa memory.hfa \
 		containers/maybe.hfa containers/pair.hfa containers/result.hfa containers/vector.hfa
 
Index: libcfa/src/Makefile.in
===================================================================
--- libcfa/src/Makefile.in	(revision 4e7c0fc0090de26380183bc8742b335bbe1cf243)
+++ libcfa/src/Makefile.in	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
@@ -141,11 +141,11 @@
 	bits/debug.cfa assert.cfa exception.c virtual.c common.cfa \
 	fstream.cfa heap.cfa iostream.cfa iterator.cfa limits.cfa \
-	rational.cfa time.cfa stdlib.cfa containers/maybe.cfa \
-	containers/pair.cfa containers/result.cfa \
+	rational.cfa time.cfa stdlib.cfa memory.cfa \
+	containers/maybe.cfa containers/pair.cfa containers/result.cfa \
 	containers/vector.cfa
 am__dirstamp = $(am__leading_dot)dirstamp
 @BUILDLIB_TRUE@am__objects_1 = common.lo fstream.lo heap.lo \
 @BUILDLIB_TRUE@	iostream.lo iterator.lo limits.lo rational.lo \
-@BUILDLIB_TRUE@	time.lo stdlib.lo containers/maybe.lo \
+@BUILDLIB_TRUE@	time.lo stdlib.lo memory.lo containers/maybe.lo \
 @BUILDLIB_TRUE@	containers/pair.lo containers/result.lo \
 @BUILDLIB_TRUE@	containers/vector.lo
@@ -238,5 +238,5 @@
 	-type f -printf "%p ") common.hfa fstream.hfa heap.hfa \
 	iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa \
-	stdlib.hfa containers/maybe.hfa containers/pair.hfa \
+	stdlib.hfa memory.hfa containers/maybe.hfa containers/pair.hfa \
 	containers/result.hfa containers/vector.hfa bitmanip.hfa \
 	exception.hfa math.hfa gmp.hfa time_t.hfa clock.hfa \
@@ -470,5 +470,6 @@
 
 @BUILDLIB_FALSE@headers = 
-@BUILDLIB_TRUE@headers = common.hfa fstream.hfa heap.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa stdlib.hfa \
+@BUILDLIB_TRUE@headers = common.hfa fstream.hfa heap.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa \
+@BUILDLIB_TRUE@		time.hfa stdlib.hfa memory.hfa \
 @BUILDLIB_TRUE@		containers/maybe.hfa containers/pair.hfa containers/result.hfa containers/vector.hfa
 
Index: libcfa/src/memory.cfa
===================================================================
--- libcfa/src/memory.cfa	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
+++ libcfa/src/memory.cfa	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
@@ -0,0 +1,172 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// memory.cfa -- Memory Management Tools for CFA
+//
+// Author           : Andrew Beach
+// Created On       : Tue Jun  2 16:48:00 2020
+// Last Modified By : Andrew Beach
+// Last Modified On : Tue Jun  3 12:30:00 2020
+// Update Count     : 0
+//
+
+#include "memory.hfa"
+#include "stdlib.hfa"
+
+// Internal data object.
+forall(dtype T | sized(T), ttype Args | { void ?{}(T &, Args); })
+void ?{}(counter_data(T) & this, Args args) {
+	(this.counter){1};
+	(this.object){args};
+}
+
+forall(dtype T | sized(T) | { void ^?{}(T &); })
+void ^?{}(counter_data(T) & this) {
+	assert(0 == this.counter);
+	^(this.object){};
+}
+
+// This is one of many pointers keeping this alive.
+forall(dtype T | sized(T))
+void ?{}(counter_ptr(T) & this) {
+	this.data = 0p;
+}
+
+forall(dtype T | sized(T))
+void ?{}(counter_ptr(T) & this, zero_t) {
+	this.data = 0p;
+}
+
+forall(dtype T | sized(T) | { void ^?{}(T &); })
+static void internal_decrement(counter_ptr(T) & this) {
+	if (this.data && 0 == --this.data->counter) {
+		delete(this.data);
+	}
+}
+
+forall(dtype T | sized(T))
+static void internal_copy(counter_ptr(T) & this, counter_ptr(T) & that) {
+	this.data = that.data;
+	if (this.data) {
+		++this.data->counter;
+	}
+}
+
+forall(dtype T | sized(T) | { void ^?{}(T &); })
+void ?{}(counter_ptr(T) & this, counter_ptr(T) that) {
+	// `that` is a copy but it should have neither a constructor
+	// nor destructor run on it so it shouldn't need adjustment.
+	internal_decrement(this);
+	internal_copy(this, that);
+}
+
+forall(dtype T | sized(T), ttype Args | { void ?{}(T&, Args); })
+void ?{}(counter_ptr(T) & this, Args args) {
+	this.data = new(args);
+}
+
+forall(dtype T | sized(T) | { void ^?{}(T &); })
+void ^?{}(counter_ptr(T) & this) {
+	internal_decrement(this);
+}
+
+forall(dtype T | sized(T))
+T & *?(counter_ptr(T) & this) {
+	return *((this.data) ? &this.data->object : 0p);
+}
+
+forall(dtype T | sized(T) | { void ^?{}(T &); })
+void ?=?(counter_ptr(T) & this, counter_ptr(T) that) {
+	if (this.data != that.data) {
+		internal_decrement(this);
+		internal_copy(this, that);
+	}
+}
+
+forall(dtype T | sized(T) | { void ^?{}(T &); })
+void ?=?(counter_ptr(T) & this, zero_t) {
+	internal_decrement(this);
+	this.data = 0p;
+}
+
+forall(dtype T | sized(T))
+int ?==?(counter_ptr(T) const & this, counter_ptr(T) const & that) {
+	return this.data == that.data;
+}
+
+forall(dtype T | sized(T))
+int ?!=?(counter_ptr(T) const & this, counter_ptr(T) const & that) {
+	return !?==?(this, that);
+}
+
+forall(dtype T | sized(T))
+int ?==?(counter_ptr(T) const & this, zero_t) {
+	return this.data == 0;
+}
+
+forall(dtype T | sized(T))
+int ?!=?(counter_ptr(T) const & this, zero_t) {
+	return !?==?(this, (zero_t)0);
+}
+
+// This is the only pointer that keeps this alive.
+forall(dtype T)
+void ?{}(unique_ptr(T) & this) {
+	this.data = 0p;
+}
+
+forall(dtype T)
+void ?{}(unique_ptr(T) & this, zero_t) {
+	this.data = 0p;
+}
+
+forall(dtype T | sized(T), ttype Args | { void ?{}(T &, Args); })
+void ?{}(unique_ptr(T) & this, Args args) {
+	this.data = new(args);
+}
+
+forall(dtype T | { void ^?{}(T &); })
+void ^?{}(unique_ptr(T) & this) {
+	delete(this.data);
+}
+
+forall(dtype T)
+T & *?(unique_ptr(T) & this) {
+	return *this.data;
+}
+
+forall(dtype T | { void ^?{}(T &); })
+void ?=?(unique_ptr(T) & this, zero_t) {
+	delete(this.data);
+	this.data = 0p;
+}
+
+forall(dtype T | { void ^?{}(T &); })
+void move(unique_ptr(T) & this, unique_ptr(T) & that) {
+	delete(this.data);
+	this.data = that.data;
+	that.data = 0p;
+}
+
+forall(dtype T)
+int ?==?(unique_ptr(T) const & this, unique_ptr(T) const & that) {
+	return this.data == that.data;
+}
+
+forall(dtype T)
+int ?!=?(unique_ptr(T) const & this, unique_ptr(T) const & that) {
+	return !?==?(this, that);
+}
+
+forall(dtype T)
+int ?==?(unique_ptr(T) const & this, zero_t) {
+	return this.data == 0;
+}
+
+forall(dtype T)
+int ?!=?(unique_ptr(T) const & this, zero_t) {
+	return !?==?(this, (zero_t)0);
+}
Index: libcfa/src/memory.hfa
===================================================================
--- libcfa/src/memory.hfa	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
+++ libcfa/src/memory.hfa	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
@@ -0,0 +1,89 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// memory.hfa -- Memory Management Tools for CFA
+//
+// Author           : Andrew Beach
+// Created On       : Tue Jun  2 16:48:00 2020
+// Last Modified By : Andrew Beach
+// Last Modified On : Tue Jun  3 12:29:00 2020
+// Update Count     : 0
+//
+
+#pragma once
+
+// Internal data object.
+forall(dtype T | sized(T)) {
+	struct counter_data {
+		unsigned int counter;
+		T object;
+	};
+
+	forall(ttype Args | { void ?{}(T &, Args); })
+	void ?{}(counter_data(T) & this, Args args);
+
+	forall( | { void ^?{}(T &); })
+	void ^?{}(counter_data(T) & this);
+}
+
+// This is one of many pointers keeping this alive.
+forall(dtype T | sized(T)) {
+	struct counter_ptr {
+		counter_data(T) * data;
+	};
+
+	void ?{}(counter_ptr(T) & this);
+	void ?{}(counter_ptr(T) & this, zero_t);
+	forall( | { void ^?{}(T &); })
+	void ?{}(counter_ptr(T) & this, counter_ptr(T) that);
+	forall(ttype Args | { void ?{}(T&, Args); })
+	void ?{}(counter_ptr(T) & this, Args args);
+
+	forall( | { void ^?{}(T &); })
+	void ^?{}(counter_ptr(T) & this);
+
+	T & *?(counter_ptr(T) & this);
+
+	forall( | { void ^?{}(T &); })
+	void ?=?(counter_ptr(T) & this, counter_ptr(T) that);
+	forall( | { void ^?{}(T &); })
+	void ?=?(counter_ptr(T) & this, zero_t);
+
+	int ?==?(counter_ptr(T) const & this, counter_ptr(T) const & that);
+	int ?!=?(counter_ptr(T) const & this, counter_ptr(T) const & that);
+	int ?==?(counter_ptr(T) const & this, zero_t);
+	int ?!=?(counter_ptr(T) const & this, zero_t);
+}
+
+// This is the only pointer that keeps this alive.
+forall(dtype T) {
+	struct unique_ptr {
+		T * data;
+	};
+
+	void ?{}(unique_ptr(T) & this);
+	void ?{}(unique_ptr(T) & this, zero_t);
+	void ?{}(unique_ptr(T) & this, unique_ptr(T) that) = void;
+	forall( | sized(T), ttype Args | { void ?{}(T &, Args); })
+	void ?{}(unique_ptr(T) & this, Args args);
+
+	forall( | { void ^?{}(T &); })
+	void ^?{}(unique_ptr(T) & this);
+
+	T & *?(unique_ptr(T) & this);
+
+	void ?=?(unique_ptr(T) & this, unique_ptr(T) that) = void;
+	forall( | { void ^?{}(T &); })
+	void ?=?(unique_ptr(T) & this, zero_t);
+
+	forall( | { void ^?{}(T &); })
+	void move(unique_ptr(T) & this, unique_ptr(T) & that);
+
+	int ?==?(unique_ptr(T) const & this, unique_ptr(T) const & that);
+	int ?!=?(unique_ptr(T) const & this, unique_ptr(T) const & that);
+	int ?==?(unique_ptr(T) const & this, zero_t);
+	int ?!=?(unique_ptr(T) const & this, zero_t);
+}
Index: libcfa/src/stdlib.cfa
===================================================================
--- libcfa/src/stdlib.cfa	(revision 4e7c0fc0090de26380183bc8742b335bbe1cf243)
+++ libcfa/src/stdlib.cfa	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
@@ -9,7 +9,7 @@
 // Author           : Peter A. Buhr
 // Created On       : Thu Jan 28 17:10:29 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jun  2 08:44:46 2020
-// Update Count     : 499
+// Last Modified By : Andrew Beach
+// Last Modified On : Tue Jun  2 16:46:00 2020
+// Update Count     : 500
 //
 
@@ -78,5 +78,5 @@
 } // new
 
-forall( dtype T | sized(T) | { void ^?{}( T & ); } )
+forall( dtype T | { void ^?{}( T & ); } )
 void delete( T * ptr ) {
 	if ( ptr ) {										// ignore null
@@ -86,10 +86,7 @@
 } // delete
 
-forall( dtype T, ttype Params | sized(T) | { void ^?{}( T & ); void delete( Params ); } )
+forall( dtype T, ttype Params | { void ^?{}( T & ); void delete( Params ); } )
 void delete( T * ptr, Params rest ) {
-	if ( ptr ) {										// ignore null
-		^(*ptr){};										// run destructor
-		free( ptr );
-	} // if
+	delete( ptr );
 	delete( rest );
 } // delete
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision 4e7c0fc0090de26380183bc8742b335bbe1cf243)
+++ libcfa/src/stdlib.hfa	(revision aabb8468c120ebc4454ffa322b8210f1bc72774b)
@@ -9,7 +9,7 @@
 // Author           : Peter A. Buhr
 // Created On       : Thu Jan 28 17:12:35 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jun  2 09:05:16 2020
-// Update Count     : 450
+// Last Modified By : Andrew Beach
+// Last Modified On : Tue Jun  2 16:47:00 2020
+// Update Count     : 451
 //
 
@@ -229,6 +229,6 @@
 // Cforall allocation/deallocation and constructor/destructor, non-array types
 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) T * new( Params p );
-forall( dtype T | sized(T) | { void ^?{}( T & ); } ) void delete( T * ptr );
-forall( dtype T, ttype Params | sized(T) | { void ^?{}( T & ); void delete( Params ); } ) void delete( T * ptr, Params rest );
+forall( dtype T | { void ^?{}( T & ); } ) void delete( T * ptr );
+forall( dtype T, ttype Params | { void ^?{}( T & ); void delete( Params ); } ) void delete( T * ptr, Params rest );
 
 // Cforall allocation/deallocation and constructor/destructor, array types
