vfs: check userland buffers before reading them.
[haiku.git] / headers / private / shared / TypeOperation.h
blobecbe619fd8a8c8134c78ef6f3fa8307eb3c31f9a
1 /*
2 * Copyright 2014, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Based on TypeOp in "C++-Templates, The Complete Guide", which is
6 * Copyright 2003 by Pearson Education, Inc.
7 */
8 #ifndef _TYPE_OPERATION_H
9 #define _TYPE_OPERATION_H
11 namespace BPrivate {
14 // Generic type conversion operations.
15 template<typename T>
16 class TypeOperation {
17 public:
18 typedef T ArgT;
19 typedef T BareT;
20 typedef T const ConstT;
22 typedef T& RefT;
23 typedef T& BareRefT;
24 typedef T const& ConstRefT;
28 // Specialization for constant types.
29 template<typename T>
30 class TypeOperation<T const> {
31 public:
32 typedef T const ArgT;
33 typedef T BareT;
34 typedef T const ConstT;
36 typedef T const& RefT;
37 typedef T& BareRefT;
38 typedef T const& ConstRefT;
42 // Specialization for reference types.
43 template<typename T>
44 class TypeOperation<T&> {
45 public:
46 typedef T& ArgT;
47 typedef typename TypeOperation<T>::BareT BareT;
48 typedef T const ConstT;
50 typedef T& RefT;
51 typedef typename TypeOperation<T>::BareRefT BareRefT;
52 typedef T const& ConstRefT;
56 // Specialization for void.
57 template<>
58 class TypeOperation<void> {
59 public:
60 typedef void ArgT;
61 typedef void BareT;
62 typedef void const ConstT;
64 typedef void RefT;
65 typedef void BareRefT;
66 typedef void ConstRefT;
70 } // namespace BPrivate
73 using BPrivate::TypeOperation;
76 #endif // _TYPE_OPERATION_H