aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-28 21:48:57 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 03:26:16 +0100
commitf1e473480062295181b9641990f48be17a9a892d (patch)
treee9b15d49360d6738cd709bf7d457f9e3058eaee5
parent2dd11396fbc7f8c26f5f9536b3d5c702a82ea4b1 (diff)
downloadpaludis-f1e473480062295181b9641990f48be17a9a892d.tar.gz
paludis-f1e473480062295181b9641990f48be17a9a892d.tar.xz
Make it easier to explicitly instantiate Pool<>
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/pool-fwd.hh29
-rw-r--r--paludis/util/pool-impl.hh11
-rw-r--r--paludis/util/pool.hh3
4 files changed, 40 insertions, 5 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 3ef3243..2e8efb4 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -60,7 +60,7 @@ add(`operators', `hh')
add(`options', `hh', `fwd', `cc', `gtest')
add(`pimp', `hh', `impl')
add(`pipe', `hh', `cc')
-add(`pool', `hh', `cc', `impl', `gtest')
+add(`pool', `hh', `cc', `impl', `gtest', `fwd')
add(`pretty_print', `hh', `cc', `gtest')
add(`process', `hh', `cc', `fwd', `gtest', `testscript')
add(`pty', `hh', `cc', `gtest')
diff --git a/paludis/util/pool-fwd.hh b/paludis/util/pool-fwd.hh
new file mode 100644
index 0000000..f5350e4
--- /dev/null
+++ b/paludis/util/pool-fwd.hh
@@ -0,0 +1,29 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_POOL_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_POOL_FWD_HH 1
+
+namespace paludis
+{
+ template <typename T_>
+ class Pool;
+}
+
+#endif
diff --git a/paludis/util/pool-impl.hh b/paludis/util/pool-impl.hh
index d7aa2db..aa02d22 100644
--- a/paludis/util/pool-impl.hh
+++ b/paludis/util/pool-impl.hh
@@ -66,7 +66,9 @@ namespace paludis
}
template <typename T_>
- Pool<T_>::~Pool() = default;
+ Pool<T_>::~Pool()
+ {
+ }
template <typename T_>
struct PreventConversion
@@ -87,7 +89,7 @@ namespace paludis
template <typename T_>
template <typename... Args_>
const std::shared_ptr<const T_>
- Pool<T_>::create(Args_ ... args) const
+ Pool<T_>::create(const Args_ & ... args) const
{
PoolKeys keys;
keys.add(args...);
@@ -95,7 +97,10 @@ namespace paludis
Lock lock(_imp->mutex);
auto i(_imp->store.find(keys));
if (i == _imp->store.end())
- i = _imp->store.insert(std::make_pair(keys, std::make_shared<const T_>(PreventConversion<Args_>(args)...))).first;
+ {
+ /* std::make_shared<> doesn't play well with private ctors */
+ i = _imp->store.insert(std::make_pair(keys, std::shared_ptr<const T_>(new T_(PreventConversion<Args_>(args)...)))).first;
+ }
else
++_imp->reused;
diff --git a/paludis/util/pool.hh b/paludis/util/pool.hh
index 58e919b..6ad9420 100644
--- a/paludis/util/pool.hh
+++ b/paludis/util/pool.hh
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_UTIL_POOL_HH
#define PALUDIS_GUARD_PALUDIS_UTIL_POOL_HH 1
+#include <paludis/util/pool-fwd.hh>
#include <paludis/util/singleton.hh>
#include <paludis/util/pimp.hh>
#include <memory>
@@ -43,7 +44,7 @@ namespace paludis
public:
template <typename... Args_>
- const std::shared_ptr<const T_> create(Args_ ...) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::shared_ptr<const T_> create(const Args_ & ...) const PALUDIS_ATTRIBUTE((warn_unused_result));
};
class PALUDIS_VISIBLE PoolKey