root / windows / trunk / libs / poco / include / Poco / MetaProgramming.h @ 23
View | Annotate | Download (3.1 KB)
| 1 | 23 | jake | //
|
|---|---|---|---|
| 2 | 23 | jake | // TypeChecks.h
|
| 3 | 23 | jake | //
|
| 4 | 23 | jake | // $Id: //poco/1.3/Foundation/include/Poco/MetaProgramming.h#1 $
|
| 5 | 23 | jake | //
|
| 6 | 23 | jake | // Library: Foundation
|
| 7 | 23 | jake | // Package: Core
|
| 8 | 23 | jake | // Module: MetaProgramming
|
| 9 | 23 | jake | //
|
| 10 | 23 | jake | // Common definitions useful for Meta Template Programming
|
| 11 | 23 | jake | //
|
| 12 | 23 | jake | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
| 13 | 23 | jake | // and Contributors.
|
| 14 | 23 | jake | //
|
| 15 | 23 | jake | // Permission is hereby granted, free of charge, to any person or organization
|
| 16 | 23 | jake | // obtaining a copy of the software and accompanying documentation covered by
|
| 17 | 23 | jake | // this license (the "Software") to use, reproduce, display, distribute,
|
| 18 | 23 | jake | // execute, and transmit the Software, and to prepare derivative works of the
|
| 19 | 23 | jake | // Software, and to permit third-parties to whom the Software is furnished to
|
| 20 | 23 | jake | // do so, all subject to the following:
|
| 21 | 23 | jake | //
|
| 22 | 23 | jake | // The copyright notices in the Software and this entire statement, including
|
| 23 | 23 | jake | // the above license grant, this restriction and the following disclaimer,
|
| 24 | 23 | jake | // must be included in all copies of the Software, in whole or in part, and
|
| 25 | 23 | jake | // all derivative works of the Software, unless such copies or derivative
|
| 26 | 23 | jake | // works are solely in the form of machine-executable object code generated by
|
| 27 | 23 | jake | // a source language processor.
|
| 28 | 23 | jake | //
|
| 29 | 23 | jake | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 30 | 23 | jake | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 31 | 23 | jake | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
| 32 | 23 | jake | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
| 33 | 23 | jake | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
| 34 | 23 | jake | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 35 | 23 | jake | // DEALINGS IN THE SOFTWARE.
|
| 36 | 23 | jake | //
|
| 37 | 23 | jake | |
| 38 | 23 | jake | |
| 39 | 23 | jake | #ifndef Foundation_TypeChecks_INCLUDED
|
| 40 | 23 | jake | #define Foundation_TypeChecks_INCLUDED
|
| 41 | 23 | jake | |
| 42 | 23 | jake | |
| 43 | 23 | jake | #include "Poco/Foundation.h" |
| 44 | 23 | jake | |
| 45 | 23 | jake | |
| 46 | 23 | jake | namespace Poco {
|
| 47 | 23 | jake | |
| 48 | 23 | jake | |
| 49 | 23 | jake | template <typename T> |
| 50 | 23 | jake | struct IsReference
|
| 51 | 23 | jake | ///Use this struct to determine if a template type is a reference
|
| 52 | 23 | jake | {
|
| 53 | 23 | jake | enum
|
| 54 | 23 | jake | {
|
| 55 | 23 | jake | VALUE = 0
|
| 56 | 23 | jake | }; |
| 57 | 23 | jake | }; |
| 58 | 23 | jake | |
| 59 | 23 | jake | |
| 60 | 23 | jake | template <typename T> |
| 61 | 23 | jake | struct IsReference<T&>
|
| 62 | 23 | jake | {
|
| 63 | 23 | jake | enum
|
| 64 | 23 | jake | {
|
| 65 | 23 | jake | VALUE = 1
|
| 66 | 23 | jake | }; |
| 67 | 23 | jake | }; |
| 68 | 23 | jake | |
| 69 | 23 | jake | |
| 70 | 23 | jake | template <typename T> |
| 71 | 23 | jake | struct IsReference<const T&> |
| 72 | 23 | jake | {
|
| 73 | 23 | jake | enum
|
| 74 | 23 | jake | {
|
| 75 | 23 | jake | VALUE = 1
|
| 76 | 23 | jake | }; |
| 77 | 23 | jake | }; |
| 78 | 23 | jake | |
| 79 | 23 | jake | |
| 80 | 23 | jake | |
| 81 | 23 | jake | template <typename T> |
| 82 | 23 | jake | struct IsConst
|
| 83 | 23 | jake | ///Use this struct to determine if a template type is a const type
|
| 84 | 23 | jake | {
|
| 85 | 23 | jake | enum
|
| 86 | 23 | jake | {
|
| 87 | 23 | jake | VALUE = 0
|
| 88 | 23 | jake | }; |
| 89 | 23 | jake | }; |
| 90 | 23 | jake | |
| 91 | 23 | jake | |
| 92 | 23 | jake | template <typename T> |
| 93 | 23 | jake | struct IsConst<const T&> |
| 94 | 23 | jake | {
|
| 95 | 23 | jake | enum
|
| 96 | 23 | jake | {
|
| 97 | 23 | jake | VALUE = 1
|
| 98 | 23 | jake | }; |
| 99 | 23 | jake | }; |
| 100 | 23 | jake | |
| 101 | 23 | jake | |
| 102 | 23 | jake | template <typename T> |
| 103 | 23 | jake | struct IsConst<const T> |
| 104 | 23 | jake | {
|
| 105 | 23 | jake | enum
|
| 106 | 23 | jake | {
|
| 107 | 23 | jake | VALUE = 1
|
| 108 | 23 | jake | }; |
| 109 | 23 | jake | }; |
| 110 | 23 | jake | |
| 111 | 23 | jake | |
| 112 | 23 | jake | template <typename T> |
| 113 | 23 | jake | struct TypeWrapper
|
| 114 | 23 | jake | /// Use the type wrapper if you want to dedecouple constness and references from template types
|
| 115 | 23 | jake | {
|
| 116 | 23 | jake | typedef T TYPE;
|
| 117 | 23 | jake | typedef const T CONSTTYPE; |
| 118 | 23 | jake | typedef T& REFTYPE;
|
| 119 | 23 | jake | typedef const T& CONSTREFTYPE; |
| 120 | 23 | jake | }; |
| 121 | 23 | jake | |
| 122 | 23 | jake | |
| 123 | 23 | jake | template <typename T> |
| 124 | 23 | jake | struct TypeWrapper<const T> |
| 125 | 23 | jake | {
|
| 126 | 23 | jake | typedef T TYPE;
|
| 127 | 23 | jake | typedef const T CONSTTYPE; |
| 128 | 23 | jake | typedef T& REFTYPE;
|
| 129 | 23 | jake | typedef const T& CONSTREFTYPE; |
| 130 | 23 | jake | }; |
| 131 | 23 | jake | |
| 132 | 23 | jake | |
| 133 | 23 | jake | template <typename T> |
| 134 | 23 | jake | struct TypeWrapper<const T&> |
| 135 | 23 | jake | {
|
| 136 | 23 | jake | typedef T TYPE;
|
| 137 | 23 | jake | typedef const T CONSTTYPE; |
| 138 | 23 | jake | typedef T& REFTYPE;
|
| 139 | 23 | jake | typedef const T& CONSTREFTYPE; |
| 140 | 23 | jake | }; |
| 141 | 23 | jake | |
| 142 | 23 | jake | |
| 143 | 23 | jake | template <typename T> |
| 144 | 23 | jake | struct TypeWrapper<T&>
|
| 145 | 23 | jake | {
|
| 146 | 23 | jake | typedef T TYPE;
|
| 147 | 23 | jake | typedef const T CONSTTYPE; |
| 148 | 23 | jake | typedef T& REFTYPE;
|
| 149 | 23 | jake | typedef const T& CONSTREFTYPE; |
| 150 | 23 | jake | }; |
| 151 | 23 | jake | |
| 152 | 23 | jake | |
| 153 | 23 | jake | |
| 154 | 23 | jake | } // namespace Poco
|
| 155 | 23 | jake | |
| 156 | 23 | jake | |
| 157 | 23 | jake | #endif |
