diff --git a/headers/build/private/shared/TypeOperation.h b/headers/build/private/shared/TypeOperation.h new file mode 100644 index 0000000000..198dbb0b49 --- /dev/null +++ b/headers/build/private/shared/TypeOperation.h @@ -0,0 +1 @@ +#include <../private/shared/TypeOperation.h> diff --git a/headers/private/kernel/util/OpenHashTable.h b/headers/private/kernel/util/OpenHashTable.h index b8804cb212..c58fba5445 100644 --- a/headers/private/kernel/util/OpenHashTable.h +++ b/headers/private/kernel/util/OpenHashTable.h @@ -13,6 +13,9 @@ #ifdef _KERNEL_MODE # include # include +# include +#else +# include #endif @@ -136,7 +139,7 @@ public: return fItemCount; } - ValueType* Lookup(const KeyType& key) const + ValueType* Lookup(typename TypeOperation::ConstRefT key) const { if (fTableSize == 0) return NULL; @@ -364,7 +367,7 @@ public: return Iterator(this); } - Iterator GetIterator(const KeyType& key) const + Iterator GetIterator(typename TypeOperation::ConstRefT key) const { if (fTableSize == 0) return Iterator(this, fTableSize, NULL); diff --git a/headers/private/kernel/util/TypeOperation.h b/headers/private/kernel/util/TypeOperation.h new file mode 100644 index 0000000000..917188bcbc --- /dev/null +++ b/headers/private/kernel/util/TypeOperation.h @@ -0,0 +1 @@ +#include <../shared/TypeOperation.h> diff --git a/headers/private/shared/TypeOperation.h b/headers/private/shared/TypeOperation.h new file mode 100644 index 0000000000..ecbe619fd8 --- /dev/null +++ b/headers/private/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 +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 +class TypeOperation { +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 +class TypeOperation { +public: + typedef T& ArgT; + typedef typename TypeOperation::BareT BareT; + typedef T const ConstT; + + typedef T& RefT; + typedef typename TypeOperation::BareRefT BareRefT; + typedef T const& ConstRefT; +}; + + +// Specialization for void. +template<> +class TypeOperation { +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 diff --git a/src/add-ons/kernel/file_systems/packagefs/volume/PackagesDirectory.h b/src/add-ons/kernel/file_systems/packagefs/volume/PackagesDirectory.h index 2d55a350d0..0ea70253d1 100644 --- a/src/add-ons/kernel/file_systems/packagefs/volume/PackagesDirectory.h +++ b/src/add-ons/kernel/file_systems/packagefs/volume/PackagesDirectory.h @@ -61,7 +61,7 @@ private: struct PackagesDirectoryHashDefinition { - typedef const node_ref KeyType; + typedef const node_ref& KeyType; typedef PackagesDirectory ValueType; size_t HashKey(const node_ref& key) const