Revert 6f68e52 and fix the gcc2 build via template.
* Instead of forcing the hash-table to use a copy of the key, introduce and use TypeOperation template to avoid taking a reference of a reference type (which gcc2 doesn't allow).
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
#include <../private/shared/TypeOperation.h>
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
#ifdef _KERNEL_MODE
|
#ifdef _KERNEL_MODE
|
||||||
# include <KernelExport.h>
|
# include <KernelExport.h>
|
||||||
# include <util/kernel_cpp.h>
|
# include <util/kernel_cpp.h>
|
||||||
|
# include <util/TypeOperation.h>
|
||||||
|
#else
|
||||||
|
# include <TypeOperation.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +139,7 @@ public:
|
|||||||
return fItemCount;
|
return fItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueType* Lookup(const KeyType& key) const
|
ValueType* Lookup(typename TypeOperation<KeyType>::ConstRefT key) const
|
||||||
{
|
{
|
||||||
if (fTableSize == 0)
|
if (fTableSize == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -364,7 +367,7 @@ public:
|
|||||||
return Iterator(this);
|
return Iterator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator GetIterator(const KeyType& key) const
|
Iterator GetIterator(typename TypeOperation<KeyType>::ConstRefT key) const
|
||||||
{
|
{
|
||||||
if (fTableSize == 0)
|
if (fTableSize == 0)
|
||||||
return Iterator(this, fTableSize, NULL);
|
return Iterator(this, fTableSize, NULL);
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
#include <../shared/TypeOperation.h>
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Based on TypeOp in "C++-Templates, The Complete Guide", which is
|
||||||
|
* Copyright 2003 by Pearson Education, Inc.
|
||||||
|
*/
|
||||||
|
#ifndef _TYPE_OPERATION_H
|
||||||
|
#define _TYPE_OPERATION_H
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
|
// Generic type conversion operations.
|
||||||
|
template<typename T>
|
||||||
|
class TypeOperation {
|
||||||
|
public:
|
||||||
|
typedef T ArgT;
|
||||||
|
typedef T BareT;
|
||||||
|
typedef T const ConstT;
|
||||||
|
|
||||||
|
typedef T& RefT;
|
||||||
|
typedef T& BareRefT;
|
||||||
|
typedef T const& ConstRefT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Specialization for constant types.
|
||||||
|
template<typename T>
|
||||||
|
class TypeOperation<T const> {
|
||||||
|
public:
|
||||||
|
typedef T const ArgT;
|
||||||
|
typedef T BareT;
|
||||||
|
typedef T const ConstT;
|
||||||
|
|
||||||
|
typedef T const& RefT;
|
||||||
|
typedef T& BareRefT;
|
||||||
|
typedef T const& ConstRefT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Specialization for reference types.
|
||||||
|
template<typename T>
|
||||||
|
class TypeOperation<T&> {
|
||||||
|
public:
|
||||||
|
typedef T& ArgT;
|
||||||
|
typedef typename TypeOperation<T>::BareT BareT;
|
||||||
|
typedef T const ConstT;
|
||||||
|
|
||||||
|
typedef T& RefT;
|
||||||
|
typedef typename TypeOperation<T>::BareRefT BareRefT;
|
||||||
|
typedef T const& ConstRefT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Specialization for void.
|
||||||
|
template<>
|
||||||
|
class TypeOperation<void> {
|
||||||
|
public:
|
||||||
|
typedef void ArgT;
|
||||||
|
typedef void BareT;
|
||||||
|
typedef void const ConstT;
|
||||||
|
|
||||||
|
typedef void RefT;
|
||||||
|
typedef void BareRefT;
|
||||||
|
typedef void ConstRefT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::TypeOperation;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _TYPE_OPERATION_H
|
||||||
@@ -61,7 +61,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
struct PackagesDirectoryHashDefinition {
|
struct PackagesDirectoryHashDefinition {
|
||||||
typedef const node_ref KeyType;
|
typedef const node_ref& KeyType;
|
||||||
typedef PackagesDirectory ValueType;
|
typedef PackagesDirectory ValueType;
|
||||||
|
|
||||||
size_t HashKey(const node_ref& key) const
|
size_t HashKey(const node_ref& key) const
|
||||||
|
|||||||
Reference in New Issue
Block a user