2023-02-08 11:04:11 +00:00
|
|
|
//
|
|
|
|
// MetaProgramming.h
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Core
|
|
|
|
// Module: MetaProgramming
|
|
|
|
//
|
|
|
|
// Common definitions useful for Meta Template Programming
|
|
|
|
//
|
|
|
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Foundation_MetaProgramming_INCLUDED
|
|
|
|
#define Foundation_MetaProgramming_INCLUDED
|
|
|
|
|
|
|
|
|
|
|
|
#include "Poco/Foundation.h"
|
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct IsReference
|
2023-02-13 09:22:33 +00:00
|
|
|
/// Use this struct to determine if a template type is a reference.
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE = 0
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2023-02-13 09:22:33 +00:00
|
|
|
struct IsReference<T &>
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE = 1
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2023-02-13 09:22:33 +00:00
|
|
|
struct IsReference<const T &>
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE = 1
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct IsConst
|
2023-02-13 09:22:33 +00:00
|
|
|
/// Use this struct to determine if a template type is a const type.
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE = 0
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2023-02-13 09:22:33 +00:00
|
|
|
struct IsConst<const T &>
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE = 1
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct IsConst<const T>
|
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE = 1
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, int i>
|
|
|
|
struct IsConst<const T[i]>
|
2023-02-13 09:22:33 +00:00
|
|
|
/// Specialization for const char arrays
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE = 1
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct TypeWrapper
|
2023-02-13 09:22:33 +00:00
|
|
|
/// Use the type wrapper if you want to decouple constness and references from template types.
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
typedef T TYPE;
|
|
|
|
typedef const T CONSTTYPE;
|
|
|
|
typedef T & REFTYPE;
|
|
|
|
typedef const T & CONSTREFTYPE;
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct TypeWrapper<const T>
|
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
typedef T TYPE;
|
|
|
|
typedef const T CONSTTYPE;
|
|
|
|
typedef T & REFTYPE;
|
|
|
|
typedef const T & CONSTREFTYPE;
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2023-02-13 09:22:33 +00:00
|
|
|
struct TypeWrapper<const T &>
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
typedef T TYPE;
|
|
|
|
typedef const T CONSTTYPE;
|
|
|
|
typedef T & REFTYPE;
|
|
|
|
typedef const T & CONSTREFTYPE;
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2023-02-13 09:22:33 +00:00
|
|
|
struct TypeWrapper<T &>
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
2023-02-13 09:22:33 +00:00
|
|
|
typedef T TYPE;
|
|
|
|
typedef const T CONSTTYPE;
|
|
|
|
typedef T & REFTYPE;
|
|
|
|
typedef const T & CONSTREFTYPE;
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|
|
|
|
|
|
|
|
|
|
|
|
#endif // Foundation_MetaProgramming_INCLUDED
|