aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-13 15:42:02 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-13 15:42:02 +0000
commitd72c9d13daefb6e329b2d80faca940f77912b2fd (patch)
treebef1e854d486e5314beb2ba1692455f0bce00757
parent596beaa6c2b6811c8299cbc401b168493e1d80ed (diff)
downloadpaludis-d72c9d13daefb6e329b2d80faca940f77912b2fd.tar.gz
paludis-d72c9d13daefb6e329b2d80faca940f77912b2fd.tar.xz
Make non-dereferencing use cleaner
-rw-r--r--paludis/util/active_object_ptr.hh7
-rw-r--r--paludis/util/active_object_ptr_TEST.cc17
-rw-r--r--paludis/util/deferred_construction_ptr.hh7
3 files changed, 28 insertions, 3 deletions
diff --git a/paludis/util/active_object_ptr.hh b/paludis/util/active_object_ptr.hh
index d3cce21..3344093 100644
--- a/paludis/util/active_object_ptr.hh
+++ b/paludis/util/active_object_ptr.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -87,6 +87,11 @@ namespace paludis
{
return Deref(this);
}
+
+ const T_ & value() const
+ {
+ return Deref(this).operator->();
+ }
};
}
diff --git a/paludis/util/active_object_ptr_TEST.cc b/paludis/util/active_object_ptr_TEST.cc
index c88dd89..8430d62 100644
--- a/paludis/util/active_object_ptr_TEST.cc
+++ b/paludis/util/active_object_ptr_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -47,5 +47,20 @@ namespace test_cases
TEST_CHECK_EQUAL(q->length(), 5u);
}
} test_dereference;
+
+ struct TestValue : TestCase
+ {
+ TestValue() : TestCase("value") { }
+
+ void run()
+ {
+ ActiveObjectPtr<std::string *> p(new std::string("monkey"));
+ TEST_CHECK_EQUAL(p.value()->length(), 6u);
+
+ ActiveObjectPtr<std::tr1::shared_ptr<std::string> > q(
+ make_shared_ptr(new std::string("chimp")));
+ TEST_CHECK_EQUAL(q.value()->length(), 5u);
+ }
+ } test_value;
}
diff --git a/paludis/util/deferred_construction_ptr.hh b/paludis/util/deferred_construction_ptr.hh
index f84b909..4e040e9 100644
--- a/paludis/util/deferred_construction_ptr.hh
+++ b/paludis/util/deferred_construction_ptr.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -70,6 +70,11 @@ namespace paludis
return _ptr;
}
+
+ T_ value() const
+ {
+ return operator-> ();
+ }
};
}