aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 22:10:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 22:10:34 +0000
commit06b60937b02e4c817b035656ab81d4254cde8dba (patch)
tree4167e07196f84decd12e6f4380bf83bb46616e8a
parente277ec331fd127f4d48ed04f8bda2a2a3cb3d3ef (diff)
downloadpaludis-06b60937b02e4c817b035656ab81d4254cde8dba.tar.gz
paludis-06b60937b02e4c817b035656ab81d4254cde8dba.tar.xz
Work around silly linkers that try to optimise out registrations
-rw-r--r--paludis/virtual_constructor.hh31
1 files changed, 7 insertions, 24 deletions
diff --git a/paludis/virtual_constructor.hh b/paludis/virtual_constructor.hh
index ce7dd00..bb87a9d 100644
--- a/paludis/virtual_constructor.hh
+++ b/paludis/virtual_constructor.hh
@@ -106,26 +106,6 @@ namespace paludis
}
/**
- * Thrown if registering a key fails.
- *
- * \ingroup Exception
- * \ingroup VirtualConstructor
- */
- class VirtualConstructorRegisterFailure : public Exception
- {
- public:
- /**
- * Constructor.
- */
- template <typename T_>
- VirtualConstructorRegisterFailure(const T_ & k) throw () :
- Exception("Virtual constructor registration failed on key '" +
- stringify(k) + "'")
- {
- }
- };
-
- /**
* A VirtualConstructor can be used where a mapping between the value of
* some key type (often a string) to the construction of some kind of
* class (possibly via a functor) is required.
@@ -235,10 +215,13 @@ namespace paludis
VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::register_maker(
const KeyType_ & k, const ValueType_ & v)
{
- if (! entries.insert(std::lower_bound(entries.begin(), entries.end(), k,
- virtual_constructor_internals::ComparePairByFirst<KeyType_, ValueType_>()),
- std::make_pair(k, v))->second)
- throw VirtualConstructorRegisterFailure(k);
+ std::pair<
+ typename std::vector<std::pair<KeyType_, ValueType_> >::iterator,
+ typename std::vector<std::pair<KeyType_, ValueType_> >::iterator > m(
+ std::equal_range(entries.begin(), entries.end(), k,
+ virtual_constructor_internals::ComparePairByFirst<KeyType_, ValueType_>()));
+ if (m.first == m.second)
+ entries.insert(m.first, std::make_pair(k, v));
}
template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>