From cc8f5ebc273ee0e24717468864ad16130ff6d192 Mon Sep 17 00:00:00 2001 From: Christos Houtouridis Date: Tue, 23 Oct 2018 00:50:03 +0300 Subject: [PATCH] impl: Add first files (untested) --- include/utl/impl/concepts.h | 46 +++++++++++++++++++++++++++++++++++ include/utl/impl/crtp.h | 48 +++++++++++++++++++++++++++++++++++++ include/utl/impl/version.h | 40 +++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100755 include/utl/impl/concepts.h create mode 100755 include/utl/impl/crtp.h create mode 100755 include/utl/impl/version.h diff --git a/include/utl/impl/concepts.h b/include/utl/impl/concepts.h new file mode 100755 index 0000000..b597c05 --- /dev/null +++ b/include/utl/impl/concepts.h @@ -0,0 +1,46 @@ +/*! + * \file /utl/impl/concepts.h + * \brief Concept support header + * + * Copyright (C) 2018 Christos Choutouridis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ +#ifndef __utl_impl_concepts_h__ +#define __utl_impl_concepts_h__ + +#include + +/*! + * utl inner concept preprecessor flag + * \defgroup crtp + * \ingroup impl + */ +//!@{ +#if defined __cpp_concepts +#define _utl_have_concepts (1) +#endif + +/*! + * requires keyword wraper + */ +#if defined _utl_have_concepts + #define _requires(_r_) requires (_r_) +#else + #define _requires(_r_) +#endif + +//!@} +#endif /* __utl_impl_concepts_h__ */ diff --git a/include/utl/impl/crtp.h b/include/utl/impl/crtp.h new file mode 100755 index 0000000..9258a87 --- /dev/null +++ b/include/utl/impl/crtp.h @@ -0,0 +1,48 @@ +/*! + * \file /utl/impl/crtp.h + * \brief CRTP idiom support header + * + * Copyright (C) 2018 Christos Choutouridis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ +#ifndef __utl_impl_crtp_h__ +#define __utl_impl_crtp_h__ + +#include + +/*! + * \defgroup crtp CRTP idiom support header + * \ingroup impl + * + * utl supports both CRTP idiom and dynamic polymorphism. By default + * CRTP is the preferred way. If the user need virtuals then instead of + * CRTP type, the \ref virtual_tag can passed to base class. The rest + * will handled by utl automatically. + */ +//!@{ +namespace utl { + //! CRTP support tag type + struct crtp_tag { }; + //! virtual support tag type + struct virtual_tag { }; + + //! \def CRTP boilerplate lines + #define _CRTP_IMPL(T) \ + constexpr T& impl() { return *static_cast(this); } \ + constexpr const T& impl() const { return *static_cast(this); } +} +//!@} +#endif /* __utl_impl_crtp_h__ */ diff --git a/include/utl/impl/version.h b/include/utl/impl/version.h new file mode 100755 index 0000000..a15b6f5 --- /dev/null +++ b/include/utl/impl/version.h @@ -0,0 +1,40 @@ +/*! + * \file /utl/impl/version.h + * \brief version and cpp version check + * + * Copyright (C) 2018 Christos Choutouridis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ +#ifndef __utl_impl_crtp_h__ +#define __utl_impl_crtp_h__ + +//!\defgroup version version +//! Definitions of the utl version +//!\ingroup impl + +#define UTL_VERSION "0.0.0" +#define UTL_VERSION_MAJOR 0 +#define UTL_VERSION_MINOR 0 +#define UTL_VERSION_PATCH 0 +#define UTL_VERSION_VALUE ( (UTL_VERSION_MAJOR * 10000) \ + + (UTL_VERSION_MINOR * 100) \ + + UTL_VERSION_PATCH) + +#if __cplusplus < 201103L +#error "Sorry. uTL requires C++11" +#endif + +#endif /* __utl_impl_crtp_h__ */