summaryrefslogtreecommitdiff
path: root/indra/llcommon/llregistry.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-07-18 15:51:34 -0400
committerNat Goodspeed <nat@lindenlab.com>2012-07-18 15:51:34 -0400
commit7f609b6a6958f519bb1becb604132b583ada3fad (patch)
tree0ec9f6eaeacd0f87181a8097c2537ba36696e57f /indra/llcommon/llregistry.h
parent18bd525d00ee3ce16164900293ee6ea8c2204589 (diff)
Backed out changeset a25bfa87418d (using std::type_info::name())
The changeset above touched every consumer of the two LLRegistrySingletons originally defined with std::type_info* as keys. Those two LLRegistrySingletons were changed to use const char* as keys, then all consumers were changed to pass std::type_info::name() instead of the plain std::type_info* pointer -- to deal with the observed fact that on Linux, a given type might produce different std::type_info* pointers in different load modules. Since then, Richard turned up the fascinating fact that at least some implementations of gcc's std::type_info::before() method already accommodate this peculiarity. It seems worth backing out the (dismayingly pervasive) change to see if properly using std::type_info::before() as the map comparator will work just as well, with conceptually simpler source code. This backout is transitional: we don't expect things to build/run properly until we've cherry-picked certain other pertinent changes.
Diffstat (limited to 'indra/llcommon/llregistry.h')
-rw-r--r--indra/llcommon/llregistry.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/indra/llcommon/llregistry.h b/indra/llcommon/llregistry.h
index 843c169f3d..36d7f7a44c 100644
--- a/indra/llcommon/llregistry.h
+++ b/indra/llcommon/llregistry.h
@@ -30,8 +30,8 @@
#include <list>
#include <boost/type_traits.hpp>
-#include <boost/static_assert.hpp>
#include "llsingleton.h"
+#include "lltypeinfolookup.h"
template <typename T>
class LLRegistryDefaultComparator
@@ -39,17 +39,27 @@ class LLRegistryDefaultComparator
bool operator()(const T& lhs, const T& rhs) { return lhs < rhs; }
};
+template <typename KEY, typename VALUE>
+struct LLRegistryMapSelector
+{
+ typedef std::map<KEY, VALUE> type;
+};
+
+template <typename VALUE>
+struct LLRegistryMapSelector<std::type_info*, VALUE>
+{
+ typedef LLTypeInfoLookup<VALUE> type;
+};
+
+template <typename VALUE>
+struct LLRegistryMapSelector<const std::type_info*, VALUE>
+{
+ typedef LLTypeInfoLookup<VALUE> type;
+};
+
template <typename KEY, typename VALUE, typename COMPARATOR = LLRegistryDefaultComparator<KEY> >
class LLRegistry
{
- // Do not use LLRegistry with KEY = std::type_info* or KEY = const std::type_info*.
- // This is known to fail on Linux.
- // If you must use LLRegistry with dynamic type info, use KEY = const char*
- // and pass std::type_info::name(); this works across load modules.
- // Disallow both std::type_info* and const std::type_info*. First remove
- // the pointer, then remove const, then compare is_same<std::type_info>.
- BOOST_STATIC_ASSERT(! (boost::is_same<typename boost::remove_const<typename boost::remove_pointer<KEY>::type>::type, std::type_info>::value));
-
public:
typedef LLRegistry<KEY, VALUE, COMPARATOR> registry_t;
typedef typename boost::add_reference<typename boost::add_const<KEY>::type>::type ref_const_key_t;
@@ -62,7 +72,7 @@ public:
{
friend class LLRegistry<KEY, VALUE, COMPARATOR>;
public:
- typedef std::map<KEY, VALUE> registry_map_t;
+ typedef typename LLRegistryMapSelector<KEY, VALUE>::type registry_map_t;
bool add(ref_const_key_t key, ref_const_value_t value)
{