Files
poco/Foundation/include/Poco/MetaProgramming.h
Matej Kenda a6648ee8c3 Foundation simplifications with modern cpp (#5086)
* enh(Logger): simplified logging macros.

* enh(Delegate): Simplify code with constexpr and std::conditional_t.

* enh(NumericString): Simplify code with constexpr and std::is_signed_v.

* enh(MetaProgramming): Simplify code with C++17 equivalents.

* enh(Tuple): Simplify code with C++17 equivalents.

* enh(TypeList): Remove metaprogramming features that are not used.

* enh(Modules): Remove obsolete Foundation functionality

* enh(Foundation): Compile and run deprecated functionality only when POCO_TEST_DEPRECATED is enabled. Update comments for deprecated functionality.

* fix(Modules): Add missing conditional forward declarations for Foundation.
2025-12-16 07:53:45 +01:00

62 lines
1.2 KiB
C++

//
// MetaProgramming.h
//
// Library: Foundation
// Package: Core
// Module: MetaProgramming
//
// Common definitions useful for Meta Template Programming
//
// Copyright (c) 2006-2025, 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"
#include <type_traits>
namespace Poco {
template <typename T>
struct IsReference
/// Use this struct to determine if a template type is a reference.
{
static constexpr int VALUE = std::is_reference_v<T> ? 1 : 0;
};
template <typename T>
struct IsConst
/// Use this struct to determine if a template type is a const type.
{
static constexpr int VALUE = std::is_const_v<std::remove_reference_t<T>> ? 1 : 0;
};
template <typename T>
struct TypeWrapper
/// Use the type wrapper if you want to decouple constness and references from template types.
{
private:
using BaseType = std::remove_cv_t<std::remove_reference_t<T>>;
public:
using TYPE = BaseType;
using CONSTTYPE = const BaseType;
using REFTYPE = BaseType&;
using CONSTREFTYPE = const BaseType&;
};
} // namespace Poco
#endif // Foundation_MetaProgramming_INCLUDED