diff --git a/README.md b/README.md index 118daa7..b54f97f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# General Utility Library for C++17 +# General Utility Library for C++20 -The General Utility Library for C++17 (GUL17) contains often-used utility functions and +The General Utility Library for C++20 (GUL20) contains often-used utility functions and types that form the foundation for other libraries and programs. The main fields covered by the library are: @@ -15,7 +15,7 @@ by the library are: * Backports from new standard library extensions To get started, have a look at the -[documentation website](https://gul-cpp.github.io/gul17/). +[documentation website](https://gul-cpp.github.io/gul20/). Here you find more detailed information on: @@ -29,20 +29,13 @@ Here you find more detailed information on: * [Versioning](#Versioning) * [Version number examples](#Version-number-examples) -## Installing with vcpkg - -GUL17 is available from the [vcpkg](https://vcpkg.io/) package manager. Once you have -vcpkg installed, just run: - -vcpkg install gul17 - ## Building -Needless to say, GUL17 needs a C++17 compliant compiler. To get started, clone this +Needless to say, GUL20 needs a C++20 compliant compiler. To get started, clone this repository: - git clone https://github.com/gul-cpp/gul17.git - cd gul17 + git clone https://github.com/gul-cpp/gul20.git + cd gul20 Use meson to configure the build you want to have. A list of the [build options](#Build-configuration-switches) is given below. Build directory name can be @@ -181,9 +174,9 @@ generate the HTML pages. ## Versioning -The version number for GUL17 resides in the LIBNO file. +The version number for GUL20 resides in the LIBNO file. -GUL17 follows a calendar-oriented versioning scheme with a version number of the +GUL20 follows a calendar-oriented versioning scheme with a version number of the form YY.M.minor where YY stands for the last two digits of the year, M is the number of the month, and minor is a minor version number that starts from zero for each release in that month. diff --git a/data/Doxyfile.in b/data/Doxyfile.in index 126415c..c270404 100644 --- a/data/Doxyfile.in +++ b/data/Doxyfile.in @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "General Utility Library for C++17" +PROJECT_NAME = "General Utility Library for C++20" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -811,7 +811,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = include/gul17/catch.h +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/data/doxygen.h b/data/doxygen.h index 2f19ed4..eb65e86 100644 --- a/data/doxygen.h +++ b/data/doxygen.h @@ -4,7 +4,7 @@ * \date Created on August 24, 2018 * \brief Doxygen input file for the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -23,7 +23,7 @@ /** * Namespace gul17 contains all functions and classes of the General Utility Library. */ -namespace gul17 { +namespace GULNS { /** * \mainpage @@ -32,7 +32,7 @@ namespace gul17 { * * \section introduction Introduction * - * The General Utility Library for C++17 (GUL17) contains often-used utility functions and + * The General Utility Library for C++20 (GUL20) contains often-used utility functions and * types that form the foundation for other libraries and programs. The main fields * covered by the library are: * @@ -58,9 +58,9 @@ namespace gul17 { * We strive for a very high quality level. To ensure this, we follow a list of * \ref quality_standards. * - * \section who_is_using_the_library Who Is Using GUL17? + * \section who_is_using_the_library Who Is Using GUL20? * - * GUL17 was developed at the German national particle accelerator laboratory + * GUL20 was developed at the German national particle accelerator laboratory * DESY. It was originally meant to provide a modern and * well-tested foundation for the DOOCS control * system which drives most of the lab's accelerators. It is still used mainly in this @@ -71,27 +71,31 @@ namespace gul17 { * * To use the library: * - * - Include the main header file \ref gul17/gul.h (or read more under + * - Include the main header file \ref gul20/gul.h (or read more under * \ref how_to_include_gul_headers). - * - Link your code against the library (-lgul17). + * - Link your code against the library (-lgul20). * - If you are on Windows, see \ref using_gul_on_windows. * - * All functions and classes are enclosed in the namespace \ref gul17. + * All functions and classes are enclosed in the namespace \ref gul20. * - * GUL17 requires at least C++17. It works fine with newer versions of the standard, but - * might use its own backport types (e.g. gul17::expected) in function interfaces. + * GUL20 requires at least C++20. It works fine with newer versions of the standard, but + * might use its own backport types (e.g. gul20::expected) in function interfaces. * * \section installation Installation * + * \if GUL20_VCPKG_READY * If you are using the [vcpkg](https://vcpkg.io/) package manager, you can install the * library simply by running: - * \verbatim vcpkg install gul17\endverbatim - * Otherwise, you may have to build and install it manually. Have a look at the - * [readme file on GitHub](https://github.com/gul-cpp/gul17/blob/main/README.md). + * \verbatim vcpkg install gul20\endverbatim + * Otherwise, you may have to build and install it manually. + * \endif + * + * Have a look at the + * [readme file on GitHub](https://github.com/gul-cpp/gul20/blob/main/README.md). * * \section source_code Obtaining the Source Code * - * You can browse or clone the source code at https://github.com/gul-cpp/gul17.git. + * You can browse or clone the source code at https://github.com/gul-cpp/gul20.git. * * \section contributing Contributing * @@ -112,38 +116,44 @@ namespace gul17 { */ /** - * \page how_to_include_gul_headers How to Include GUL17 Headers + * \page how_to_include_gul_headers How to Include GUL20 Headers * - * All header files of the library reside under `gul17/` with no further subdirectories. - * To get access to almost all of GUL17's functionality, it is sufficient to include the + * All header files of the library reside under `gul20/` with no further subdirectories. + * To get access to almost all of GUL20's functionality, it is sufficient to include the * all-in-one header: * \code - * #include + * #include * \endcode * - * Howard Hinnant's `gul17/date.h` header for calendar date functionality is not included + * Howard Hinnant's `gul20/date.h` header for calendar date functionality is not included * in this header file, chiefly because of its negative impact on compile times. Just * include it directly where needed. * * If you prefer to shave the last seconds off your build times, you are of course free to - * include also the other GUL17 headers individually without going through `gul.h`. Just + * include also the other GUL20 headers individually without going through `gul.h`. Just * follow the documentation of the classes and functions you use to find the associated * header files. * * We do not guarantee that individual header file names will never change (except for - * `gul17/gul.h`), but we can assure you that this will happen rarely, if ever. + * `gul20/gul.h`), but we can assure you that this will happen rarely, if ever. */ /** * \page release_notes Release Notes * - * GUL17 releases follow a calendar-oriented versioning scheme with a version number of + * GUL20 releases follow a calendar-oriented versioning scheme with a version number of * the form `YY.M.minor` where `YY` stands for the last two digits of the year, `M` is the * number of the month, and `minor` is a minor version number that starts from zero for - * each release in that month. For instance, the first release in March 2025 was called - * 25.3.0, the second could have been called 24.3.1. This is not semantic + * each release in that month. For instance, the first release in February 2026 was called + * 26.2.0, the second could have been called 26.2.1. This is not semantic * versioning. * + * \section changelog_gul20 GUL20 Versions + * + * - Initial release of GUL20. Compared to GUL17, backports of C++20 standard library + * features (e.g. span, remove_cvref) are removed. + * + * * \section changelog_gul17 GUL17 Versions * * \subsection V26_2_0 Version 26.2.0 @@ -176,6 +186,7 @@ namespace gul17 { * features (e.g. string_view, optional) are removed, and the build system is * simplified. * + * * \section changelog_2_x GUL14: 2.x Versions * * \subsection V2_13_0 Version 2.13.0 @@ -354,14 +365,14 @@ namespace gul17 { * * The following individuals contributed to the General Utility Library: * - * > Lars Fröhlich, Sören Grunewald, Olaf Hensler, Fini Jastrow, Josef Wilgen + * > Jan Behrens, Lars Fröhlich, Sören Grunewald, Olaf Hensler, Fini Jastrow * * Additional code distributed with this library was written by authors listed under * \ref additional_copyright_notices below. * * \section copyright_notice Copyright Notice * - * Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -393,11 +404,6 @@ namespace gul17 { * dedicated all copyright and related and neighboring rights to this software to the * public domain worldwide. This software is distributed without any warranty. * \ref license_cc0_public_domain and \ref expected.h for details). - * - *
\ref span.h
- *
Copyright 2018 Tristan Brindle. - * Distributed under the Boost Software License, Version 1.0 (see - * \ref license_boost_1_0 and \ref span.h for details).
* */ @@ -536,7 +542,7 @@ namespace gul17 { * Furthermore, the library includes Howard Hinnant's date.h header, which extends C++17's * `` library with types and functionality for handling calendar dates. Most of * this functionality has been standardized in C++20. Documentation is available on - * [GitHub](https://howardhinnant.github.io/date/date.html); just note that the GUL17 + * [GitHub](https://howardhinnant.github.io/date/date.html); just note that the GUL20 * version lives in the namespace `gul17::date`. */ @@ -667,12 +673,6 @@ namespace gul17 { * \ref gul17::OverloadSet "OverloadSet": * A class template that works like an overload set of functions, mainly for use with * std::visit(). - * - * \ref gul17::remove_cvref "remove_cvref": - * A metafunction to remove const, volatile, and reference qualifiers from a type. - * This is a backport of - * [std::remove_cvref](https://en.cppreference.com/w/cpp/types/remove_cvref) from - * C++20. */ /** @@ -691,17 +691,6 @@ namespace gul17 { * error value. It should behave like * [std::expected](https://en.cppreference.com/w/cpp/utility/expected) * from C++23 for almost all use cases. - * - * \ref gul17::remove_cvref "remove_cvref": - * A metafunction to remove const, volatile, and reference qualifiers from a type. - * This is a backport of - * [std::remove_cvref](https://en.cppreference.com/w/cpp/types/remove_cvref) from - * C++20. - * - * \ref gul17::span "span": - * A view to a contiguous sequence of objects. It should behave like - * [std::span](https://en.cppreference.com/w/cpp/container/span) from C++20 for almost - * all use cases. */ /** @@ -711,10 +700,6 @@ namespace gul17 { * version 3 for its unit tests. Please refer to * https://github.com/catchorg/Catch2/blob/master/docs/tutorial.md for an introduction to * Catch2. - * - * \note - * The predecessor library GUL14 included a header-only version of Catch2. This header is - * no longer available in GUL17. Catch2 must be installed separately. */ /** @@ -980,9 +965,9 @@ namespace gul17 { */ /** - * \defgroup date_h gul17/date.h + * \defgroup date_h gul20/date.h * \brief Calendar date library by Howard Hinnant. * \see https://github.com/HowardHinnant/date */ -} // namespace gul17 +} // namespace GULNS diff --git a/data/how_to_create_a_vcpkg_port.txt b/data/how_to_create_a_vcpkg_port.txt index 419f1e7..a0296d3 100644 --- a/data/how_to_create_a_vcpkg_port.txt +++ b/data/how_to_create_a_vcpkg_port.txt @@ -1,17 +1,17 @@ -These are some notes on how to create a new vcpkg port for GUL17, e.g. after the +These are some notes on how to create a new vcpkg port for GUL20, e.g. after the release of an update. This assumes that a fork of https://github.com/microsoft/vcpkg.git is checked out. -1. Edit ports/gul17/portfile.cmake +1. Edit ports/gul20/portfile.cmake Change REF to new version tag or git hash Change SHA512 to 0 -2. Edit ports/gul17/vcpkg.json +2. Edit ports/gul20/vcpkg.json Change version number 3. Run vcpkg remove --outdated - This should remove the outdated GUL17 version (if any) + This should remove the outdated GUL20 version (if any) 4. Run vcpkg install gul17 It should fail and show you the new SHA512 hash -5. Edit ports/gul17/portfile.cmake +5. Edit ports/gul20/portfile.cmake Change SHA512 to new hash 6. Add port to vcpkg repository git add ports/gul17 diff --git a/debian/copyright b/debian/copyright index 783121d..6a2e508 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,15 +1,10 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Files: * -Copyright: 2018-2024 libgul contributors - 2018-2024 DESY +Copyright: 2018-2026 Deutsches Elektronen-Synchrotron (DESY) License: LGPL-2.1+ -Files: include/gul17/catch.h -Copyright: 2019 Two Blue Cubes Ltd. -License: BSL-1.0 - -Files: include/gul17/date.h +Files: include/gul20/date.h Copyright: 2015-2017 Howard Hinnant 2016 Adrian Colomitchi 2017 Florian Dang @@ -19,16 +14,11 @@ Copyright: 2015-2017 Howard Hinnant 2022 libgul contributors (L. Fröhlich) License: Expat -Files: include/gul17/expected.h +Files: include/gul20/expected.h Copyright: 2017 Sy Brand 2023-2024 libgul contributors (L. Fröhlich) License: CC0 -Files: include/gul17/span.h -Copyright: 2018 Tristan Brindle - 2019 libgul contributors (L. Fröhlich) -License: BSL-1.0 - License: LGPL-2.1+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -44,31 +34,6 @@ License: LGPL-2.1+ License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -License: BSL-1.0 - Boost Software License - Version 1.0 - August 17th, 2003 - . - Permission is hereby granted, free of charge, to any person or organization - obtaining a copy of the software and accompanying documentation covered by - this license (the "Software") to use, reproduce, display, distribute, - execute, and transmit the Software, and to prepare derivative works of the - Software, and to permit third-parties to whom the Software is furnished to - do so, all subject to the following: - . - The copyright notices in the Software and this entire statement, including - the above license grant, this restriction and the following disclaimer, - must be included in all copies of the Software, in whole or in part, and - all derivative works of the Software, unless such copies or derivative - works are solely in the form of machine-executable object code generated by - a source language processor. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT - SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE - FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/examples/thread_pool.cc b/examples/thread_pool.cc index 30973bb..eb45f3c 100644 --- a/examples/thread_pool.cc +++ b/examples/thread_pool.cc @@ -4,7 +4,7 @@ * \date Created on February 9, 2024 * \brief Example on how to use the ThreadPool. * - * \copyright Copyright 2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2024-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -22,10 +22,10 @@ #include -#include -#include +#include +#include -using namespace gul17; +using namespace GULNS; using std::cout; using namespace std::literals; @@ -37,7 +37,7 @@ int main() auto pool = make_thread_pool(2); pool->add_task([]() { cout << "Task 1\n"; }); - pool->add_task([]() { sleep(1); std::cout << "Task 2\n"; }); + pool->add_task([]() { sleep(1.0); std::cout << "Task 2\n"; }); // Tasks can be scheduled to start later: // This one should start 2 seconds after enqueueing (if a thread is available) diff --git a/examples/trim.cc b/examples/trim.cc index ce02483..9e0dbec 100644 --- a/examples/trim.cc +++ b/examples/trim.cc @@ -21,14 +21,14 @@ */ #include -#include +#include -using gul17::trim_left_sv; -using gul17::trim_left; -using gul17::trim_right_sv; -using gul17::trim_right; -using gul17::trim_sv; -using gul17::trim; +using GULNS::trim_left_sv; +using GULNS::trim_left; +using GULNS::trim_right_sv; +using GULNS::trim_right; +using GULNS::trim_sv; +using GULNS::trim; using std::cout; int main() diff --git a/gul17.spec b/gul17.spec deleted file mode 100644 index bb35f24..0000000 --- a/gul17.spec +++ /dev/null @@ -1,107 +0,0 @@ -# -# This file is used to build RPMS for gul17 -# -# To use it do the following: -# -# 1) create a dist tarball -# $ meson build && ninja -C build dist -# -# 2) Prepare the rpm build environment -# $ pkcon install rpmdevtools -# $ rpmdev-setuptree -# $ cp build/meson-dist/gul17-.tar.xz ~/rpmbuild/SOURCES -# $ cp gul17.spec ~/rpmbuild/SPECS -# -# 3) Build the package -# $ cd ~/rpmbuild -# $ rpmbuild -ba SPECS/gul17.spec -# -# https://rpm-packaging-guide.github.io/ -# - -Name: gul17 -Version: 25.4.1 -Release: 1%{?dist} -Summary: General Utility Library - -License: LGPL-2.1+ -URL: https://github.com/gul-cpp/gul17 -Source0: gul17-%{version}.tar.xz - -%if 0%{?rhel} < 8 -BuildRequires: devtoolset-7-gcc-c++ -# This is needed to fix an issue with the currently meson -# package, it might be obsolete as soon as a new meson -# package is rolled out. -BuildRequires: epel-rpm-macros -%endif -BuildRequires: gcc-c++ -BuildRequires: meson -BuildRequires: ninja-build -# we actually use some git checks in meson -BuildRequires: git-core - -%description -The general utility library for C++17 contains often-used -utility functions and types that form the foundation for -other libraries and programs. - -%package devel -Summary: Development libraries and header files for %{name} -Requires: %{name}%{?_isa} = %{version}-%{release} -# We can use BuildRequire: pkgconfig(gul17) -# in using projects to automatically use either one: -##Requires: pkgconfig -##Requires: pkgconf-pkg-config - -%description devel -%{summary}. - -%package static -Summary: Static libraries for %{name} -Requires: %{name}-devel%{?_isa} = %{version}-%{release} - -%description static -%{summary}. - -%ifarch %{arm} aarch64 -# Disable the creation of debug packages on ARM -%global debug_package %{nil} -%endif - -%prep -%setup -q -n gul17-%{version} - -%build -%meson -%meson_build - -%install -%meson_install - -%check -%meson_test - -%files -%{_libdir}/lib%{name}.so.* - -%files devel -%{_libdir}/lib%{name}.so -%{_libdir}/pkgconfig/%{name}.pc -%{_includedir}/gul17/* - -%files static -%{_libdir}/lib%{name}.a - -%changelog -* Mon Jun 16 2025 Fini Jastrow - 25.4.1-1 -- New upstream release - -* Fri Feb 16 2024 Soeren Grunewald - 2.10-1 -- New upstream release - -* Thu Oct 13 2022 Soeren Grunewald - 2.7-1 -- New upstream release - -* Thu Aug 19 2021 Soeren Grunewald - 2.6-1 -- Initial release diff --git a/include/gul17/span.h b/include/gul17/span.h deleted file mode 100644 index 687c3a5..0000000 --- a/include/gul17/span.h +++ /dev/null @@ -1,567 +0,0 @@ -/** - * \file span.h - * \author Tristan Brindle - * \brief Provides a gul17::span that mimicks C++20's std::span as closely as possible. - * - * \copyright - * Copyright Tristan Brindle 2018. - * Copyright Deutsches Elektronen-Synchrotron (DESY), Hamburg 2019-2025 (modifications for - * GUL, \ref contributors). - * - * Distributed under the Boost Software License, Version 1.0. (See \ref license_boost_1_0 - * or http://www.boost.org/LICENSE_1_0.txt) - * - * For more information, see http://www.boost.org - * - * This is an implementation of C++20's std::span - * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4820.pdf - */ - -#ifndef GUL17_SPAN_H_ -#define GUL17_SPAN_H_ - -#include -#include -#include -#include -#include -#include - -#include "gul17/traits.h" - -namespace gul17 { - -/** - * \addtogroup span_h gul17/span.h - * \brief Backport of std::span from C++20. - * @{ - */ - -/// \cond HIDE_SYMBOLS - -constexpr std::size_t dynamic_extent = SIZE_MAX; - -template -class span; - -namespace detail { - -template -struct span_storage { - constexpr span_storage() noexcept = default; - - constexpr span_storage(E* pointer, std::size_t /*unused*/) noexcept : ptr(pointer) - {} - - E* ptr = nullptr; - static constexpr std::size_t size = S; -}; - -template -struct span_storage { - constexpr span_storage() noexcept = default; - - constexpr span_storage(E* pointer, std::size_t sz) noexcept - : ptr(pointer), size(sz) - {} - - E* ptr = nullptr; - std::size_t size = 0; -}; - -template -constexpr auto size(const C& c) -> decltype(c.size()) -{ - return c.size(); -} - -template -constexpr std::size_t size(const T (&)[N]) noexcept -{ - return N; -} - -template -constexpr auto data(C& c) -> decltype(c.data()) -{ - return c.data(); -} - -template -constexpr auto data(const C& c) -> decltype(c.data()) -{ - return c.data(); -} - -template -constexpr T* data(T (&array)[N]) noexcept -{ - return array; -} - -template -constexpr const E* data(std::initializer_list il) noexcept -{ - return il.begin(); -} - -template -struct is_span : std::false_type {}; - -template -struct is_span> : std::true_type {}; - -template -struct is_std_array : std::false_type {}; - -template -struct is_std_array> : std::true_type {}; - -template -struct has_size_and_data : std::false_type {}; - -template -struct has_size_and_data())), - decltype(detail::data(std::declval()))>> - : std::true_type {}; - -template > -struct is_container { - static constexpr bool value = - !is_span::value && !is_std_array::value && - !std::is_array::value && has_size_and_data::value; -}; - -template -using remove_pointer_t = typename std::remove_pointer::type; - -template -struct is_container_element_type_compatible : std::false_type {}; - -template -struct is_container_element_type_compatible< - T, E, std::void_t()))>> - : std::is_convertible< - remove_pointer_t()))> (*)[], - E (*)[]> {}; - -template -struct is_complete : std::false_type {}; - -template -struct is_complete : std::true_type {}; - -} // namespace detail - - -/// \endcond - - -/** - * A view to a contiguous sequence of objects. This is a backport of - * [std::span](https://en.cppreference.com/w/cpp/container/span) from C++20. - * - * \since GUL version 1.9 - */ -template -class span { - static_assert(std::is_object::value, - "A span's ElementType must be an object type (not a " - "reference type or void)"); - static_assert(detail::is_complete::value, - "A span's ElementType must be a complete type (not a forward " - "declaration)"); - static_assert(!std::is_abstract::value, - "A span's ElementType cannot be an abstract class type"); - - using storage_type = detail::span_storage; - -public: - // constants and types - using element_type = ElementType; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using value_type = typename std::remove_cv::type; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using index_type = std::size_t; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using difference_type = std::ptrdiff_t; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using pointer = element_type*; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using const_pointer = const element_type*; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using reference = element_type&; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using iterator = pointer; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using const_iterator = const_pointer; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using reverse_iterator = std::reverse_iterator; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - using const_reverse_iterator = std::reverse_iterator; ///< See [std::span](https://en.cppreference.com/w/cpp/container/span). - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - static constexpr index_type extent = Extent; - - // [span.cons], span constructors, copy, assignment, and destructor - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template < - std::size_t E = Extent, - typename std::enable_if<(E == dynamic_extent || E <= 0), int>::type = 0> - constexpr span() noexcept - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr span(pointer ptr, index_type count) - : storage_(ptr, count) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr span(pointer first_elem, pointer last_elem) - : storage_(first_elem, static_cast(last_elem - first_elem)) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template ::value, - int>::type = 0> - constexpr span(element_type (&arr)[N]) noexcept : storage_(arr, N) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template &, ElementType>::value, - int>::type = 0> - span(std::array& arr) noexcept - : storage_(arr.data(), N) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template &, ElementType>::value, - int>::type = 0> - span(const std::array& arr) noexcept - : storage_(arr.data(), N) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template < - typename Container, std::size_t E = Extent, - typename std::enable_if< - E == dynamic_extent && detail::is_container::value && - detail::is_container_element_type_compatible< - Container&, ElementType>::value, - int>::type = 0> - constexpr span(Container& cont) - : storage_(detail::data(cont), detail::size(cont)) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template < - typename Container, std::size_t E = Extent, - typename std::enable_if< - E == dynamic_extent && detail::is_container::value && - detail::is_container_element_type_compatible< - const Container&, ElementType>::value, - int>::type = 0> - constexpr span(const Container& cont) - : storage_(detail::data(cont), detail::size(cont)) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr span(const span& other) noexcept = default; - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template ::value, - int>::type = 0> - constexpr span(const span& other) noexcept - : storage_(other.data(), other.size()) - {} - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - ~span() noexcept = default; - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr span& - operator=(const span& other) noexcept = default; - - // [span.sub], span subviews - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template - constexpr span first() const - { - return {data(), Count}; - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template - constexpr span last() const - { - return {data() + (size() - Count), Count}; - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template - using subspan_return_t = - span; - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - template - constexpr subspan_return_t subspan() const - { - return {data() + Offset, - Count != dynamic_extent ? Count : size() - Offset}; - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr span - first(index_type count) const - { - return {data(), count}; - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr span - last(index_type count) const - { - return {data() + (size() - count), count}; - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr span - subspan(index_type offset, index_type count = dynamic_extent) const - { - return {data() + offset, - count == dynamic_extent ? size() - offset : count}; - } - - // [span.obs], span observers - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr index_type size() const noexcept { return storage_.size; } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr index_type size_bytes() const noexcept - { - return size() * sizeof(element_type); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr bool empty() const noexcept - { - return size() == 0; - } - - // [span.elem], span element access - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr reference operator[](index_type idx) const - { - return *(data() + idx); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr reference front() const - { - return *data(); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr reference back() const - { - return *(data() + (size() - 1)); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr pointer data() const noexcept { return storage_.ptr; } - - // [span.iterators], span iterator support - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr iterator begin() const noexcept { return data(); } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr iterator end() const noexcept { return data() + size(); } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr const_iterator cbegin() const noexcept { return begin(); } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - constexpr const_iterator cend() const noexcept { return end(); } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - reverse_iterator rbegin() const noexcept - { - return reverse_iterator(end()); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - reverse_iterator rend() const noexcept - { - return reverse_iterator(begin()); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - const_reverse_iterator crbegin() const noexcept - { - return const_reverse_iterator(cend()); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - const_reverse_iterator crend() const noexcept - { - return const_reverse_iterator(cbegin()); - } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - friend constexpr iterator begin(span s) noexcept { return s.begin(); } - - /// See [std::span](https://en.cppreference.com/w/cpp/container/span). - friend constexpr iterator end(span s) noexcept { return s.end(); } - -private: - storage_type storage_{}; -}; - -/// \cond HIDE_SYMBOLS - -/* Comparison operators */ -// Implementation note: the implementations of == and < are equivalent to -// 4-legged std::equal and std::lexicographical_compare respectively - -template -constexpr bool operator==(span lhs, span rhs) -{ - if (lhs.size() != rhs.size()) { - return false; - } - - for (std::size_t i = 0; i < lhs.size(); i++) { - if (lhs[i] != rhs[i]) { - return false; - } - } - - return true; -} - -template -constexpr bool operator!=(span lhs, span rhs) -{ - return !(lhs == rhs); -} - -template -constexpr bool operator<(span lhs, span rhs) -{ - // No std::min to avoid dragging in - const std::size_t size = lhs.size() < rhs.size() ? lhs.size() : rhs.size(); - - for (std::size_t i = 0; i < size; i++) { - if (lhs[i] < rhs[i]) { - return true; - } - if (lhs[i] > rhs[i]) { - return false; - } - } - return lhs.size() < rhs.size(); -} - -template -constexpr bool operator<=(span lhs, span rhs) -{ - return !(rhs < lhs); -} - -template -constexpr bool operator>(span lhs, span rhs) -{ - return rhs < lhs; -} - -template -constexpr bool operator>=(span lhs, span rhs) -{ - return !(lhs < rhs); -} - -/// \endcond - -/** - * Return a constant view to the byte representation of the elements of a given span. - * - * This is a backport from the C++20 standard library, see: - * https://en.cppreference.com/w/cpp/container/span/as_bytes - * - * \since GUL version 1.9 - */ -template -span -as_bytes(span s) noexcept -{ - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -/** - * Return a writable view to the byte representation of the elements of a given span. - * - * This is a backport from the C++20 standard library, see: - * https://en.cppreference.com/w/cpp/container/span/as_bytes - * - * \since GUL version 1.9 - */ -template < - class ElementType, size_t Extent, - typename std::enable_if::value, int>::type = 0> -span -as_writable_bytes(span s) noexcept -{ - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -/** - * Return a reference to the Nth element of a given span. - * - * This is a backport from the C++20 standard library, see: - * https://en.cppreference.com/w/cpp/container/span/get - * - * \since GUL version 1.9 - */ -template -constexpr auto get(span s) -> decltype(s[N]) -{ - return s[N]; -} - -/// @} - -} // namespace gul17 - - -namespace std { - -template -class tuple_size> - : public integral_constant {}; - -template -class tuple_size>; // not defined - -template -class tuple_element> { -public: - static_assert(Extent != gul17::dynamic_extent && I < Extent, ""); - using type = ElementType; -}; - -} // namespace std - -#endif - -// vi:ts=4:sw=4:sts=4:et diff --git a/include/gul17/OverloadSet.h b/include/gul20/OverloadSet.h similarity index 88% rename from include/gul17/OverloadSet.h rename to include/gul20/OverloadSet.h index 982a82f..ae7ade1 100644 --- a/include/gul17/OverloadSet.h +++ b/include/gul20/OverloadSet.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 15 June 2023 * - * \copyright Copyright 2023-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2023-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,13 +20,13 @@ * along with this program. If not, see . */ -#ifndef GUL17_OVERLOADSET_H_ -#define GUL17_OVERLOADSET_H_ +#ifndef GUL20_OVERLOADSET_H_ +#define GUL20_OVERLOADSET_H_ -namespace gul17 { +namespace GULNS { /** - * \addtogroup variant_h gul17/variant.h + * \addtogroup variant_h gul20/variant.h * \brief Implementation of the OverloadSet class template. * @{ */ @@ -37,7 +37,7 @@ namespace gul17 { * \code{.cpp} * std::variant v = 1.0; * auto str = std::visit( - * gul17::OverloadSet{ + * GULNS::OverloadSet{ * [](char) { return "char"; }, * [](int) { return "int"; } * }, v); @@ -62,6 +62,6 @@ struct OverloadSet : Fcts ... template OverloadSet(Fcts...) -> OverloadSet; -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/SlidingBuffer.h b/include/gul20/SlidingBuffer.h similarity index 99% rename from include/gul17/SlidingBuffer.h rename to include/gul20/SlidingBuffer.h index e013c36..a09ac11 100644 --- a/include/gul17/SlidingBuffer.h +++ b/include/gul20/SlidingBuffer.h @@ -4,7 +4,7 @@ * \date Created on Feb 7, 2019 * \brief Declaration of the SlidingBuffer class for the General Utility Library. * - * \copyright Copyright 2019-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,21 +20,21 @@ * along with this program. If not, see . */ -#ifndef GUL17_SLIDINGBUFFER_H_ -#define GUL17_SLIDINGBUFFER_H_ +#ifndef GUL20_SLIDINGBUFFER_H_ +#define GUL20_SLIDINGBUFFER_H_ #include #include #include #include -#include "gul17/cat.h" -#include "gul17/internal.h" +#include "gul20/cat.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup SlidingBuffer_h gul17/SlidingBuffer.h + * \addtogroup SlidingBuffer_h gul20/SlidingBuffer.h * \brief A ring buffer. * @{ */ @@ -410,7 +410,7 @@ class SlidingBuffer { { auto const s = size(); if (idx >= s) { - throw std::out_of_range(gul17::cat("SlidingBuffer::", __func__, + throw std::out_of_range(GULNS::cat("SlidingBuffer::", __func__, ": idx (which is ", idx, ") >= this->size() (which is ", s, ")")); } return operator[](idx); @@ -423,7 +423,7 @@ class SlidingBuffer { { auto const s = size(); if (idx >= s) { - throw std::out_of_range(gul17::cat("SlidingBuffer::", __func__, + throw std::out_of_range(GULNS::cat("SlidingBuffer::", __func__, ": idx (which is ", idx, ") >= this->size() (which is ", s, ")")); } return operator[](idx); @@ -1317,7 +1317,7 @@ class SlidingBufferExposed : public SlidingBuffer. */ -#ifndef GUL17_SMALLVECTOR_H_ -#define GUL17_SMALLVECTOR_H_ +#ifndef GUL20_SMALLVECTOR_H_ +#define GUL20_SMALLVECTOR_H_ #include #include @@ -33,13 +33,13 @@ #include #include -#include "gul17/internal.h" -#include "gul17/cat.h" +#include "gul20/internal.h" +#include "gul20/cat.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup SmallVector_h gul17/SmallVector.h + * \addtogroup SmallVector_h gul20/SmallVector.h * \brief A vector with small-buffer optimization. * @{ */ @@ -1661,7 +1661,7 @@ void swap(SmallVector& a, SmallVector #include @@ -36,10 +36,10 @@ #include #include -#include -#include +#include +#include -namespace gul17 { +namespace GULNS { class ThreadPool; @@ -51,7 +51,7 @@ std::shared_ptr lock_pool_or_throw(std::weak_ptr pool); } // namespace detail /** - * \addtogroup ThreadPool_h gul17/ThreadPool.h + * \addtogroup ThreadPool_h gul20/ThreadPool.h * \brief A thread pool and task queue. * @{ */ @@ -81,7 +81,7 @@ enum class TaskState * * Each task is associated with a TaskHandle. This handle is returned by add_task() and * can be used to query the status of the task or to remove it from the queue via - * \ref gul17::ThreadPool::TaskHandle::cancel() "cancel()". Tasks that are already running + * \ref GULNS::ThreadPool::TaskHandle::cancel() "cancel()". Tasks that are already running * cannot be canceled. * * \code{.cpp} @@ -630,6 +630,6 @@ inline std::shared_ptr make_thread_pool( /// @} -} // namespace gul17 +} // namespace GULNS -#endif // GUL17_THREADPOOL_H_ +#endif // GUL20_THREADPOOL_H_ diff --git a/include/gul17/Trigger.h b/include/gul20/Trigger.h similarity index 96% rename from include/gul17/Trigger.h rename to include/gul20/Trigger.h index c9b02c3..ef33508 100644 --- a/include/gul17/Trigger.h +++ b/include/gul20/Trigger.h @@ -4,7 +4,7 @@ * \date Created on September 21, 2018 * \brief Declaration of the Trigger class for the General Utility Library. * - * \copyright Copyright 2018-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,19 +20,19 @@ * along with this program. If not, see . */ -#ifndef GUL17_TRIGGER_H_ -#define GUL17_TRIGGER_H_ +#ifndef GUL20_TRIGGER_H_ +#define GUL20_TRIGGER_H_ #include #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup Trigger_h gul17/Trigger.h + * \addtogroup Trigger_h gul20/Trigger.h * \brief A cross-thread trigger. * @{ */ @@ -223,6 +223,6 @@ class Trigger /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/bit_manip.h b/include/gul20/bit_manip.h similarity index 95% rename from include/gul17/bit_manip.h rename to include/gul20/bit_manip.h index b099c5b..cd88eb0 100644 --- a/include/gul17/bit_manip.h +++ b/include/gul20/bit_manip.h @@ -5,7 +5,7 @@ * \authors \ref contributors * \date Created on 17 October 2019 * - * \copyright Copyright 2019-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -21,18 +21,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_BIT_MANIP_H_ -#define GUL17_BIT_MANIP_H_ +#ifndef GUL20_BIT_MANIP_H_ +#define GUL20_BIT_MANIP_H_ #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup bit_manip_h gul17/bit_manip.h + * \addtogroup bit_manip_h gul20/bit_manip.h * \brief Bit manipulation and testing, endianness. * @{ */ @@ -66,7 +66,7 @@ using BitFunctionReturnType = * which do not conform to either of these conventions. * * \code{.cpp} - * if constexpr (gul17::endian::native == gul17::endian::big) + * if constexpr (GULNS::endian::native == GULNS::endian::big) * std::cout << "This is a big-endian machine!\n"; * \endcode * @@ -232,7 +232,7 @@ bool constexpr inline bit_test(T bits, unsigned bit) noexcept { * In big-endian order, the most significant byte is stored first, followed by the other * bytes in order of decreasing significance. * - * \see is_little_endian(), gul17::endian + * \see is_little_endian(), GULNS::endian * \since GUL version 2.10 */ constexpr bool is_big_endian() @@ -247,7 +247,7 @@ constexpr bool is_big_endian() * In little-endian order, the least significant byte is stored first, followed by the * other bytes in order of increasing significance. * - * \see is_big_endian(), gul17::endian + * \see is_big_endian(), GULNS::endian * \since GUL version 2.10 */ constexpr bool is_little_endian() @@ -257,7 +257,7 @@ constexpr bool is_little_endian() /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/case_ascii.h b/include/gul20/case_ascii.h similarity index 94% rename from include/gul17/case_ascii.h rename to include/gul20/case_ascii.h index 84f902b..c1c3f7a 100644 --- a/include/gul17/case_ascii.h +++ b/include/gul20/case_ascii.h @@ -5,7 +5,7 @@ * \authors \ref contributors * \date Created on 28 May 2019 * - * \copyright Copyright 2019-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -21,18 +21,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_CASE_ASCII_H_ -#define GUL17_CASE_ASCII_H_ +#ifndef GUL20_CASE_ASCII_H_ +#define GUL20_CASE_ASCII_H_ #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup case_ascii_h gul17/case_ascii.h + * \addtogroup case_ascii_h gul20/case_ascii.h * \brief Converting ASCII characters to lowercase or uppercase. * @{ */ @@ -117,7 +117,7 @@ std::string& uppercase_ascii_inplace(std::string& str) noexcept; /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/cat.h b/include/gul20/cat.h similarity index 93% rename from include/gul17/cat.h rename to include/gul20/cat.h index 4c92187..9349586 100644 --- a/include/gul17/cat.h +++ b/include/gul20/cat.h @@ -5,7 +5,7 @@ * \brief Declaration of the overload set for cat() and of the associated class * ConvertingStringView. * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -21,26 +21,26 @@ * along with this program. If not, see . */ -#ifndef GUL17_CAT_H_ -#define GUL17_CAT_H_ +#ifndef GUL20_CAT_H_ +#define GUL20_CAT_H_ #include #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup cat_h gul17/cat.h + * \addtogroup cat_h gul20/cat.h * \brief Concatenation of strings and other types. * @{ */ /** * A string view that can automatically convert numbers into strings. - * This class is primarily intended for use as a parameter in gul17::cat(). + * This class is primarily intended for use as a parameter in GULNS::cat(). * For string-like arguments, it acts similar to std::string_view. Number-like * arguments (double, int, ...) are converted into strings in a default format using * std::to_string. Arguments of type char are converted into a string of length 1. @@ -88,7 +88,7 @@ class ConvertingStringView * cat() reserves the correct amount of space before concatenating the strings and can * therefore save several memory allocations compared to concatenation with "+". * \code - * std::string str = gul17::cat(13.5, std::string(" quick "), "brown foxes ", "jump over ", + * std::string str = GULNS::cat(13.5, std::string(" quick "), "brown foxes ", "jump over ", * 42, " lazy dogs'", std::string(" heads.")); * // str == "13.500000 quick brown foxes jump over 42 lazy dogs' heads." * \endcode @@ -121,6 +121,6 @@ inline std::string cat(const Args&... args) /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/date.h b/include/gul20/date.h similarity index 95% rename from include/gul17/date.h rename to include/gul20/date.h index 6dc06a7..7736480 100644 --- a/include/gul17/date.h +++ b/include/gul20/date.h @@ -37,8 +37,8 @@ * We did not mean to shout. */ -#ifndef GUL17_DATE_H_ -#define GUL17_DATE_H_ +#ifndef GUL20_DATE_H_ +#define GUL20_DATE_H_ #include #include @@ -84,7 +84,7 @@ # pragma warning(disable : 4127) #endif -namespace gul17 { +namespace GULNS { namespace date { //---------------+ @@ -441,9 +441,9 @@ class weekday_indexed public: weekday_indexed() = default; - constexpr weekday_indexed(const gul17::date::weekday& wd, unsigned index) noexcept; + constexpr weekday_indexed(const GULNS::date::weekday& wd, unsigned index) noexcept; - constexpr gul17::date::weekday weekday() const noexcept; + constexpr GULNS::date::weekday weekday() const noexcept; constexpr unsigned index() const noexcept; constexpr bool ok() const noexcept; }; @@ -459,12 +459,12 @@ operator<<(std::basic_ostream& os, const weekday_indexed& wdi); class weekday_last { - gul17::date::weekday wd_; + GULNS::date::weekday wd_; public: - explicit constexpr weekday_last(const gul17::date::weekday& wd) noexcept; + explicit constexpr weekday_last(const GULNS::date::weekday& wd) noexcept; - constexpr gul17::date::weekday weekday() const noexcept; + constexpr GULNS::date::weekday weekday() const noexcept; constexpr bool ok() const noexcept; }; @@ -486,15 +486,15 @@ struct unspecified_month_disambiguator {}; class year_month { - gul17::date::year y_; - gul17::date::month m_; + GULNS::date::year y_; + GULNS::date::month m_; public: year_month() = default; - constexpr year_month(const gul17::date::year& y, const gul17::date::month& m) noexcept; + constexpr year_month(const GULNS::date::year& y, const GULNS::date::month& m) noexcept; - constexpr gul17::date::year year() const noexcept; - constexpr gul17::date::month month() const noexcept; + constexpr GULNS::date::year year() const noexcept; + constexpr GULNS::date::month month() const noexcept; template constexpr year_month& operator+=(const months& dm) noexcept; @@ -533,15 +533,15 @@ operator<<(std::basic_ostream& os, const year_month& ym); class month_day { - gul17::date::month m_; - gul17::date::day d_; + GULNS::date::month m_; + GULNS::date::day d_; public: month_day() = default; - constexpr month_day(const gul17::date::month& m, const gul17::date::day& d) noexcept; + constexpr month_day(const GULNS::date::month& m, const GULNS::date::day& d) noexcept; - constexpr gul17::date::month month() const noexcept; - constexpr gul17::date::day day() const noexcept; + constexpr GULNS::date::month month() const noexcept; + constexpr GULNS::date::day day() const noexcept; constexpr bool ok() const noexcept; }; @@ -561,12 +561,12 @@ operator<<(std::basic_ostream& os, const month_day& md); class month_day_last { - gul17::date::month m_; + GULNS::date::month m_; public: - constexpr explicit month_day_last(const gul17::date::month& m) noexcept; + constexpr explicit month_day_last(const GULNS::date::month& m) noexcept; - constexpr gul17::date::month month() const noexcept; + constexpr GULNS::date::month month() const noexcept; constexpr bool ok() const noexcept; }; @@ -585,14 +585,14 @@ operator<<(std::basic_ostream& os, const month_day_last& mdl); class month_weekday { - gul17::date::month m_; - gul17::date::weekday_indexed wdi_; + GULNS::date::month m_; + GULNS::date::weekday_indexed wdi_; public: - constexpr month_weekday(const gul17::date::month& m, - const gul17::date::weekday_indexed& wdi) noexcept; + constexpr month_weekday(const GULNS::date::month& m, + const GULNS::date::weekday_indexed& wdi) noexcept; - constexpr gul17::date::month month() const noexcept; - constexpr gul17::date::weekday_indexed weekday_indexed() const noexcept; + constexpr GULNS::date::month month() const noexcept; + constexpr GULNS::date::weekday_indexed weekday_indexed() const noexcept; constexpr bool ok() const noexcept; }; @@ -608,15 +608,15 @@ operator<<(std::basic_ostream& os, const month_weekday& mwd); class month_weekday_last { - gul17::date::month m_; - gul17::date::weekday_last wdl_; + GULNS::date::month m_; + GULNS::date::weekday_last wdl_; public: - constexpr month_weekday_last(const gul17::date::month& m, - const gul17::date::weekday_last& wd) noexcept; + constexpr month_weekday_last(const GULNS::date::month& m, + const GULNS::date::weekday_last& wd) noexcept; - constexpr gul17::date::month month() const noexcept; - constexpr gul17::date::weekday_last weekday_last() const noexcept; + constexpr GULNS::date::month month() const noexcept; + constexpr GULNS::date::weekday_last weekday_last() const noexcept; constexpr bool ok() const noexcept; }; @@ -634,14 +634,14 @@ operator<<(std::basic_ostream& os, const month_weekday_last& mwdl class year_month_day { - gul17::date::year y_; - gul17::date::month m_; - gul17::date::day d_; + GULNS::date::year y_; + GULNS::date::month m_; + GULNS::date::day d_; public: year_month_day() = default; - constexpr year_month_day(const gul17::date::year& y, const gul17::date::month& m, - const gul17::date::day& d) noexcept; + constexpr year_month_day(const GULNS::date::year& y, const GULNS::date::month& m, + const GULNS::date::day& d) noexcept; constexpr year_month_day(const year_month_day_last& ymdl) noexcept; constexpr year_month_day(sys_days dp) noexcept; @@ -654,9 +654,9 @@ class year_month_day constexpr year_month_day& operator+=(const years& y) noexcept; constexpr year_month_day& operator-=(const years& y) noexcept; - constexpr gul17::date::year year() const noexcept; - constexpr gul17::date::month month() const noexcept; - constexpr gul17::date::day day() const noexcept; + constexpr GULNS::date::year year() const noexcept; + constexpr GULNS::date::month month() const noexcept; + constexpr GULNS::date::day day() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; @@ -692,12 +692,12 @@ operator<<(std::basic_ostream& os, const year_month_day& ymd); class year_month_day_last { - gul17::date::year y_; - gul17::date::month_day_last mdl_; + GULNS::date::year y_; + GULNS::date::month_day_last mdl_; public: - constexpr year_month_day_last(const gul17::date::year& y, - const gul17::date::month_day_last& mdl) noexcept; + constexpr year_month_day_last(const GULNS::date::year& y, + const GULNS::date::month_day_last& mdl) noexcept; template constexpr year_month_day_last& operator+=(const months& m) noexcept; @@ -706,10 +706,10 @@ class year_month_day_last constexpr year_month_day_last& operator+=(const years& y) noexcept; constexpr year_month_day_last& operator-=(const years& y) noexcept; - constexpr gul17::date::year year() const noexcept; - constexpr gul17::date::month month() const noexcept; - constexpr gul17::date::month_day_last month_day_last() const noexcept; - constexpr gul17::date::day day() const noexcept; + constexpr GULNS::date::year year() const noexcept; + constexpr GULNS::date::month month() const noexcept; + constexpr GULNS::date::month_day_last month_day_last() const noexcept; + constexpr GULNS::date::day day() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; @@ -764,14 +764,14 @@ operator<<(std::basic_ostream& os, const year_month_day_last& ymd class year_month_weekday { - gul17::date::year y_; - gul17::date::month m_; - gul17::date::weekday_indexed wdi_; + GULNS::date::year y_; + GULNS::date::month m_; + GULNS::date::weekday_indexed wdi_; public: year_month_weekday() = default; - constexpr year_month_weekday(const gul17::date::year& y, const gul17::date::month& m, - const gul17::date::weekday_indexed& wdi) noexcept; + constexpr year_month_weekday(const GULNS::date::year& y, const GULNS::date::month& m, + const GULNS::date::weekday_indexed& wdi) noexcept; constexpr year_month_weekday(const sys_days& dp) noexcept; constexpr explicit year_month_weekday(const local_days& dp) noexcept; @@ -782,11 +782,11 @@ class year_month_weekday constexpr year_month_weekday& operator+=(const years& y) noexcept; constexpr year_month_weekday& operator-=(const years& y) noexcept; - constexpr gul17::date::year year() const noexcept; - constexpr gul17::date::month month() const noexcept; - constexpr gul17::date::weekday weekday() const noexcept; + constexpr GULNS::date::year year() const noexcept; + constexpr GULNS::date::month month() const noexcept; + constexpr GULNS::date::weekday weekday() const noexcept; constexpr unsigned index() const noexcept; - constexpr gul17::date::weekday_indexed weekday_indexed() const noexcept; + constexpr GULNS::date::weekday_indexed weekday_indexed() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; @@ -837,13 +837,13 @@ operator<<(std::basic_ostream& os, const year_month_weekday& ymwd class year_month_weekday_last { - gul17::date::year y_; - gul17::date::month m_; - gul17::date::weekday_last wdl_; + GULNS::date::year y_; + GULNS::date::month m_; + GULNS::date::weekday_last wdl_; public: - constexpr year_month_weekday_last(const gul17::date::year& y, const gul17::date::month& m, - const gul17::date::weekday_last& wdl) noexcept; + constexpr year_month_weekday_last(const GULNS::date::year& y, const GULNS::date::month& m, + const GULNS::date::weekday_last& wdl) noexcept; template constexpr year_month_weekday_last& operator+=(const months& m) noexcept; @@ -852,10 +852,10 @@ class year_month_weekday_last constexpr year_month_weekday_last& operator+=(const years& y) noexcept; constexpr year_month_weekday_last& operator-=(const years& y) noexcept; - constexpr gul17::date::year year() const noexcept; - constexpr gul17::date::month month() const noexcept; - constexpr gul17::date::weekday weekday() const noexcept; - constexpr gul17::date::weekday_last weekday_last() const noexcept; + constexpr GULNS::date::year year() const noexcept; + constexpr GULNS::date::month month() const noexcept; + constexpr GULNS::date::weekday weekday() const noexcept; + constexpr GULNS::date::weekday_last weekday_last() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; @@ -908,32 +908,32 @@ operator<<(std::basic_ostream& os, const year_month_weekday_last& inline namespace literals { -constexpr gul17::date::day operator ""_d(unsigned long long d) noexcept; -constexpr gul17::date::year operator ""_y(unsigned long long y) noexcept; +constexpr GULNS::date::day operator ""_d(unsigned long long d) noexcept; +constexpr GULNS::date::year operator ""_y(unsigned long long y) noexcept; } // inline namespace literals #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) -// constexpr const gul17::date::month January{1}; -// constexpr const gul17::date::month February{2}; -// constexpr const gul17::date::month March{3}; -// constexpr const gul17::date::month April{4}; -// constexpr const gul17::date::month May{5}; -// constexpr const gul17::date::month June{6}; -// constexpr const gul17::date::month July{7}; -// constexpr const gul17::date::month August{8}; -// constexpr const gul17::date::month September{9}; -// constexpr const gul17::date::month October{10}; -// constexpr const gul17::date::month November{11}; -// constexpr const gul17::date::month December{12}; +// constexpr const GULNS::date::month January{1}; +// constexpr const GULNS::date::month February{2}; +// constexpr const GULNS::date::month March{3}; +// constexpr const GULNS::date::month April{4}; +// constexpr const GULNS::date::month May{5}; +// constexpr const GULNS::date::month June{6}; +// constexpr const GULNS::date::month July{7}; +// constexpr const GULNS::date::month August{8}; +// constexpr const GULNS::date::month September{9}; +// constexpr const GULNS::date::month October{10}; +// constexpr const GULNS::date::month November{11}; +// constexpr const GULNS::date::month December{12}; // -// constexpr const gul17::date::weekday Sunday{0u}; -// constexpr const gul17::date::weekday Monday{1u}; -// constexpr const gul17::date::weekday Tuesday{2u}; -// constexpr const gul17::date::weekday Wednesday{3u}; -// constexpr const gul17::date::weekday Thursday{4u}; -// constexpr const gul17::date::weekday Friday{5u}; -// constexpr const gul17::date::weekday Saturday{6u}; +// constexpr const GULNS::date::weekday Sunday{0u}; +// constexpr const GULNS::date::weekday Monday{1u}; +// constexpr const GULNS::date::weekday Tuesday{2u}; +// constexpr const GULNS::date::weekday Wednesday{3u}; +// constexpr const GULNS::date::weekday Thursday{4u}; +// constexpr const GULNS::date::weekday Friday{5u}; +// constexpr const GULNS::date::weekday Saturday{6u}; #if HAS_VOID_T @@ -1263,7 +1263,7 @@ std::chrono::time_point floor(const std::chrono::time_point& tp) { using std::chrono::time_point; - return time_point{gul17::date::floor(tp.time_since_epoch())}; + return time_point{GULNS::date::floor(tp.time_since_epoch())}; } // round to nearest, to even on tie @@ -1808,67 +1808,67 @@ inline namespace literals { constexpr inline -gul17::date::day +GULNS::date::day operator ""_d(unsigned long long d) noexcept { - return gul17::date::day{static_cast(d)}; + return GULNS::date::day{static_cast(d)}; } constexpr inline -gul17::date::year +GULNS::date::year operator ""_y(unsigned long long y) noexcept { - return gul17::date::year(static_cast(y)); + return GULNS::date::year(static_cast(y)); } #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) -constexpr const gul17::date::last_spec last{}; - -constexpr const gul17::date::month jan{1}; -constexpr const gul17::date::month feb{2}; -constexpr const gul17::date::month mar{3}; -constexpr const gul17::date::month apr{4}; -constexpr const gul17::date::month may{5}; -constexpr const gul17::date::month jun{6}; -constexpr const gul17::date::month jul{7}; -constexpr const gul17::date::month aug{8}; -constexpr const gul17::date::month sep{9}; -constexpr const gul17::date::month oct{10}; -constexpr const gul17::date::month nov{11}; -constexpr const gul17::date::month dec{12}; - -constexpr const gul17::date::weekday sun{0u}; -constexpr const gul17::date::weekday mon{1u}; -constexpr const gul17::date::weekday tue{2u}; -constexpr const gul17::date::weekday wed{3u}; -constexpr const gul17::date::weekday thu{4u}; -constexpr const gul17::date::weekday fri{5u}; -constexpr const gul17::date::weekday sat{6u}; +constexpr const GULNS::date::last_spec last{}; + +constexpr const GULNS::date::month jan{1}; +constexpr const GULNS::date::month feb{2}; +constexpr const GULNS::date::month mar{3}; +constexpr const GULNS::date::month apr{4}; +constexpr const GULNS::date::month may{5}; +constexpr const GULNS::date::month jun{6}; +constexpr const GULNS::date::month jul{7}; +constexpr const GULNS::date::month aug{8}; +constexpr const GULNS::date::month sep{9}; +constexpr const GULNS::date::month oct{10}; +constexpr const GULNS::date::month nov{11}; +constexpr const GULNS::date::month dec{12}; + +constexpr const GULNS::date::weekday sun{0u}; +constexpr const GULNS::date::weekday mon{1u}; +constexpr const GULNS::date::weekday tue{2u}; +constexpr const GULNS::date::weekday wed{3u}; +constexpr const GULNS::date::weekday thu{4u}; +constexpr const GULNS::date::weekday fri{5u}; +constexpr const GULNS::date::weekday sat{6u}; #if !defined(_MSC_VER) || (_MSC_VER >= 1900) } // inline namespace literals #endif -constexpr const gul17::date::month January{1}; -constexpr const gul17::date::month February{2}; -constexpr const gul17::date::month March{3}; -constexpr const gul17::date::month April{4}; -constexpr const gul17::date::month May{5}; -constexpr const gul17::date::month June{6}; -constexpr const gul17::date::month July{7}; -constexpr const gul17::date::month August{8}; -constexpr const gul17::date::month September{9}; -constexpr const gul17::date::month October{10}; -constexpr const gul17::date::month November{11}; -constexpr const gul17::date::month December{12}; - -constexpr const gul17::date::weekday Monday{1}; -constexpr const gul17::date::weekday Tuesday{2}; -constexpr const gul17::date::weekday Wednesday{3}; -constexpr const gul17::date::weekday Thursday{4}; -constexpr const gul17::date::weekday Friday{5}; -constexpr const gul17::date::weekday Saturday{6}; -constexpr const gul17::date::weekday Sunday{7}; +constexpr const GULNS::date::month January{1}; +constexpr const GULNS::date::month February{2}; +constexpr const GULNS::date::month March{3}; +constexpr const GULNS::date::month April{4}; +constexpr const GULNS::date::month May{5}; +constexpr const GULNS::date::month June{6}; +constexpr const GULNS::date::month July{7}; +constexpr const GULNS::date::month August{8}; +constexpr const GULNS::date::month September{9}; +constexpr const GULNS::date::month October{10}; +constexpr const GULNS::date::month November{11}; +constexpr const GULNS::date::month December{12}; + +constexpr const GULNS::date::weekday Monday{1}; +constexpr const GULNS::date::weekday Tuesday{2}; +constexpr const GULNS::date::weekday Wednesday{3}; +constexpr const GULNS::date::weekday Thursday{4}; +constexpr const GULNS::date::weekday Friday{5}; +constexpr const GULNS::date::weekday Saturday{6}; +constexpr const GULNS::date::weekday Sunday{7}; // weekday_indexed @@ -1876,7 +1876,7 @@ constexpr inline weekday weekday_indexed::weekday() const noexcept { - return gul17::date::weekday{static_cast(wd_)}; + return GULNS::date::weekday{static_cast(wd_)}; } constexpr inline unsigned weekday_indexed::index() const noexcept {return index_;} @@ -1893,7 +1893,7 @@ weekday_indexed::ok() const noexcept #endif // __GNUC__ constexpr inline -weekday_indexed::weekday_indexed(const gul17::date::weekday& wd, unsigned index) noexcept +weekday_indexed::weekday_indexed(const GULNS::date::weekday& wd, unsigned index) noexcept : wd_(static_cast(static_cast(wd.wd_))) , index_(static_cast(index)) {} @@ -1945,9 +1945,9 @@ operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept // weekday_last -constexpr inline gul17::date::weekday weekday_last::weekday() const noexcept {return wd_;} +constexpr inline GULNS::date::weekday weekday_last::weekday() const noexcept {return wd_;} constexpr inline bool weekday_last::ok() const noexcept {return wd_.ok();} -constexpr inline weekday_last::weekday_last(const gul17::date::weekday& wd) noexcept : wd_(wd) {} +constexpr inline weekday_last::weekday_last(const GULNS::date::weekday& wd) noexcept : wd_(wd) {} constexpr inline bool operator==(const weekday_last& x, const weekday_last& y) noexcept @@ -1994,7 +1994,7 @@ weekday::operator[](last_spec) const noexcept // year_month constexpr inline -year_month::year_month(const gul17::date::year& y, const gul17::date::month& m) noexcept +year_month::year_month(const GULNS::date::year& y, const GULNS::date::month& m) noexcept : y_(y) , m_(m) {} @@ -2147,25 +2147,25 @@ operator<<(std::basic_ostream& os, const year_month& ym) // month_day constexpr inline -month_day::month_day(const gul17::date::month& m, const gul17::date::day& d) noexcept +month_day::month_day(const GULNS::date::month& m, const GULNS::date::day& d) noexcept : m_(m) , d_(d) {} -constexpr inline gul17::date::month month_day::month() const noexcept {return m_;} -constexpr inline gul17::date::day month_day::day() const noexcept {return d_;} +constexpr inline GULNS::date::month month_day::month() const noexcept {return m_;} +constexpr inline GULNS::date::day month_day::day() const noexcept {return d_;} constexpr inline bool month_day::ok() const noexcept { - constexpr const gul17::date::day d[] = + constexpr const GULNS::date::day d[] = { - gul17::date::day(31), gul17::date::day(29), gul17::date::day(31), - gul17::date::day(30), gul17::date::day(31), gul17::date::day(30), - gul17::date::day(31), gul17::date::day(31), gul17::date::day(30), - gul17::date::day(31), gul17::date::day(30), gul17::date::day(31) + GULNS::date::day(31), GULNS::date::day(29), GULNS::date::day(31), + GULNS::date::day(30), GULNS::date::day(31), GULNS::date::day(30), + GULNS::date::day(31), GULNS::date::day(31), GULNS::date::day(30), + GULNS::date::day(31), GULNS::date::day(30), GULNS::date::day(31) }; - return m_.ok() && gul17::date::day{1} <= d_ && d_ <= d[static_cast(m_)-1]; + return m_.ok() && GULNS::date::day{1} <= d_ && d_ <= d[static_cast(m_)-1]; } constexpr inline bool @@ -2234,7 +2234,7 @@ operator<<(std::basic_ostream& os, const month_day& md) constexpr inline month month_day_last::month() const noexcept {return m_;} constexpr inline bool month_day_last::ok() const noexcept {return m_.ok();} -constexpr inline month_day_last::month_day_last(const gul17::date::month& m) noexcept : m_(m) {} +constexpr inline month_day_last::month_day_last(const GULNS::date::month& m) noexcept : m_(m) {} constexpr inline bool operator==(const month_day_last& x, const month_day_last& y) noexcept @@ -2298,8 +2298,8 @@ operator<<(std::basic_ostream& os, const month_day_last& mdl) // month_weekday constexpr inline -month_weekday::month_weekday(const gul17::date::month& m, - const gul17::date::weekday_indexed& wdi) noexcept +month_weekday::month_weekday(const GULNS::date::month& m, + const GULNS::date::weekday_indexed& wdi) noexcept : m_(m) , wdi_(wdi) {} @@ -2357,8 +2357,8 @@ operator<<(std::basic_ostream& os, const month_weekday& mwd) // month_weekday_last constexpr inline -month_weekday_last::month_weekday_last(const gul17::date::month& m, - const gul17::date::weekday_last& wdl) noexcept +month_weekday_last::month_weekday_last(const GULNS::date::month& m, + const GULNS::date::weekday_last& wdl) noexcept : m_(m) , wdl_(wdl) {} @@ -2415,8 +2415,8 @@ operator<<(std::basic_ostream& os, const month_weekday_last& mwdl // year_month_day_last -constexpr inline year_month_day_last::year_month_day_last(const gul17::date::year& y, - const gul17::date::month_day_last& mdl) noexcept +constexpr inline year_month_day_last::year_month_day_last(const GULNS::date::year& y, + const GULNS::date::month_day_last& mdl) noexcept : y_(y) , mdl_(mdl) {} @@ -2465,15 +2465,15 @@ constexpr inline day year_month_day_last::day() const noexcept { - constexpr const gul17::date::day d[] = + constexpr const GULNS::date::day d[] = { - gul17::date::day(31), gul17::date::day(28), gul17::date::day(31), - gul17::date::day(30), gul17::date::day(31), gul17::date::day(30), - gul17::date::day(31), gul17::date::day(31), gul17::date::day(30), - gul17::date::day(31), gul17::date::day(30), gul17::date::day(31) + GULNS::date::day(31), GULNS::date::day(28), GULNS::date::day(31), + GULNS::date::day(30), GULNS::date::day(31), GULNS::date::day(30), + GULNS::date::day(31), GULNS::date::day(31), GULNS::date::day(30), + GULNS::date::day(31), GULNS::date::day(30), GULNS::date::day(31) }; return (month() != February || !y_.is_leap()) && mdl_.ok() ? - d[static_cast(month()) - 1] : gul17::date::day{29}; + d[static_cast(month()) - 1] : GULNS::date::day{29}; } constexpr inline @@ -2604,8 +2604,8 @@ operator-(const year_month_day_last& ymdl, const years& dy) noexcept // year_month_day constexpr inline -year_month_day::year_month_day(const gul17::date::year& y, const gul17::date::month& m, - const gul17::date::day& d) noexcept +year_month_day::year_month_day(const GULNS::date::year& y, const GULNS::date::month& m, + const GULNS::date::day& d) noexcept : y_(y) , m_(m) , d_(d) @@ -2701,7 +2701,7 @@ year_month_day::ok() const noexcept { if (!(y_.ok() && m_.ok())) return false; - return gul17::date::day{1} <= d_ && d_ <= (y_ / m_ / last).day(); + return GULNS::date::day{1} <= d_ && d_ <= (y_ / m_ / last).day(); } constexpr inline bool @@ -2780,7 +2780,7 @@ year_month_day::from_days(days dp) noexcept auto const mp = (5*doy + 2)/153; // [0, 11] auto const d = doy - (153*mp+2)/5 + 1; // [1, 31] auto const m = mp < 10 ? mp+3 : mp-9; // [1, 12] - return year_month_day{gul17::date::year{y + (m <= 2)}, gul17::date::month(m), gul17::date::day(d)}; + return year_month_day{GULNS::date::year{y + (m <= 2)}, GULNS::date::month(m), GULNS::date::day(d)}; } template @@ -2831,8 +2831,8 @@ operator-(const year_month_day& ymd, const years& dy) noexcept // year_month_weekday constexpr inline -year_month_weekday::year_month_weekday(const gul17::date::year& y, const gul17::date::month& m, - const gul17::date::weekday_indexed& wdi) +year_month_weekday::year_month_weekday(const GULNS::date::year& y, const GULNS::date::month& m, + const GULNS::date::weekday_indexed& wdi) noexcept : y_(y) , m_(m) @@ -2926,7 +2926,7 @@ year_month_weekday::ok() const noexcept return false; if (wdi_.index() <= 4) return true; - auto d2 = wdi_.weekday() - gul17::date::weekday(static_cast(y_/m_/1)) + + auto d2 = wdi_.weekday() - GULNS::date::weekday(static_cast(y_/m_/1)) + days((wdi_.index()-1)*7 + 1); return static_cast(d2.count()) <= static_cast((y_/m_/last).day()); } @@ -2936,7 +2936,7 @@ year_month_weekday year_month_weekday::from_days(days d) noexcept { sys_days dp{d}; - auto const wd = gul17::date::weekday(dp); + auto const wd = GULNS::date::weekday(dp); auto const ymd = year_month_day(dp); return {ymd.year(), ymd.month(), wd[(static_cast(ymd.day())-1)/7+1]}; } @@ -2946,7 +2946,7 @@ days year_month_weekday::to_days() const noexcept { auto d = sys_days(y_/m_/1); - return (d + (wdi_.weekday() - gul17::date::weekday(d) + days{(wdi_.index()-1)*7}) + return (d + (wdi_.weekday() - GULNS::date::weekday(d) + days{(wdi_.index()-1)*7}) ).time_since_epoch(); } @@ -3024,9 +3024,9 @@ operator-(const year_month_weekday& ymwd, const years& dy) noexcept // year_month_weekday_last constexpr inline -year_month_weekday_last::year_month_weekday_last(const gul17::date::year& y, - const gul17::date::month& m, - const gul17::date::weekday_last& wdl) noexcept +year_month_weekday_last::year_month_weekday_last(const GULNS::date::year& y, + const GULNS::date::month& m, + const GULNS::date::weekday_last& wdl) noexcept : y_(y) , m_(m) , wdl_(wdl) @@ -3106,7 +3106,7 @@ days year_month_weekday_last::to_days() const noexcept { auto const d = sys_days(y_/m_/last); - return (d - (gul17::date::weekday{d} - wdl_.weekday())).time_since_epoch(); + return (d - (GULNS::date::weekday{d} - wdl_.weekday())).time_since_epoch(); } constexpr inline bool @@ -3586,7 +3586,7 @@ class decimal_format_seconds std::basic_ostream& print(std::basic_ostream& os, std::true_type) const { - gul17::date::detail::save_ostream _(os); + GULNS::date::detail::save_ostream _(os); std::chrono::duration d = s_ + sub_s_; if (d < std::chrono::seconds{10}) os << '0'; @@ -3599,7 +3599,7 @@ class decimal_format_seconds std::basic_ostream& print(std::basic_ostream& os, std::false_type) const { - gul17::date::detail::save_ostream _(os); + GULNS::date::detail::save_ostream _(os); os.fill('0'); os.flags(std::ios::dec | std::ios::right); os.width(2); @@ -3611,7 +3611,7 @@ class decimal_format_seconds #else os << '.'; #endif - gul17::date::detail::save_ostream _s(os); + GULNS::date::detail::save_ostream _s(os); os.imbue(std::locale::classic()); os.width(width); os << sub_s_.count(); @@ -3711,14 +3711,14 @@ class hh_mm_ss template friend std::basic_ostream& - gul17::date::to_stream(std::basic_ostream& os, const CharT* fmt, + GULNS::date::to_stream(std::basic_ostream& os, const CharT* fmt, const fields& fds, const std::string* abbrev, const std::chrono::seconds* offset_sec); template friend std::basic_istream& - gul17::date::from_stream(std::basic_istream& is, const CharT* fmt, + GULNS::date::from_stream(std::basic_istream& is, const CharT* fmt, fields& fds, std::basic_string* abbrev, std::chrono::minutes* offset); }; @@ -3788,7 +3788,7 @@ typename std::enable_if >::type operator<<(std::basic_ostream& os, const sys_time& tp) { - auto const dp = gul17::date::floor(tp); + auto const dp = GULNS::date::floor(tp); return os << year_month_day(dp) << ' ' << make_time(tp-dp); } @@ -4602,7 +4602,7 @@ to_stream(std::basic_ostream& os, const CharT* fmt, using std::chrono::seconds; using std::chrono::minutes; using std::chrono::hours; - gul17::date::detail::save_ostream ss(os); + GULNS::date::detail::save_ostream ss(os); os.fill(' '); os.flags(std::ios::skipws | std::ios::dec); os.width(0); @@ -4934,7 +4934,7 @@ to_stream(std::basic_ostream& os, const CharT* fmt, if (modified == CharT{}) #endif { - auto h = *fmt == CharT{'I'} ? gul17::date::make12(hms.hours()) : hms.hours(); + auto h = *fmt == CharT{'I'} ? GULNS::date::make12(hms.hours()) : hms.hours(); if (h < hours{10}) os << CharT{'0'}; os << h.count(); @@ -5090,7 +5090,7 @@ to_stream(std::basic_ostream& os, const CharT* fmt, tm.tm_hour = static_cast(fds.tod.hours().count()); facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); #else - if (gul17::date::is_am(fds.tod.hours())) + if (GULNS::date::is_am(fds.tod.hours())) os << ampm_names().first[0]; else os << ampm_names().first[1]; @@ -5148,12 +5148,12 @@ to_stream(std::basic_ostream& os, const CharT* fmt, save_ostream _(os); os.fill('0'); os.width(2); - os << gul17::date::make12(tod.hours()).count() << CharT{':'}; + os << GULNS::date::make12(tod.hours()).count() << CharT{':'}; os.width(2); os << tod.minutes().count() << CharT{':'}; os.width(2); os << tod.seconds().count() << CharT{' '}; - if (gul17::date::is_am(tod.hours())) + if (GULNS::date::is_am(tod.hours())) os << ampm_names().first[0]; else os << ampm_names().first[1]; @@ -5564,7 +5564,7 @@ to_stream(std::basic_ostream& os, const CharT* fmt, } auto m = duration_cast(*offset_sec); auto neg = m < minutes{0}; - m = gul17::date::abs(m); + m = GULNS::date::abs(m); auto h = duration_cast(m); m -= h; if (neg) @@ -6120,7 +6120,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, typename std::basic_istream::sentry ok{is, true}; if (ok) { - gul17::date::detail::save_istream ss(is); + GULNS::date::detail::save_istream ss(is); is.fill(' '); is.flags(std::ios::skipws | std::ios::dec); is.width(0); @@ -7449,7 +7449,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, year& y, { using CT = std::chrono::seconds; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.year().ok()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7465,7 +7465,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, month& m, { using CT = std::chrono::seconds; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.month().ok()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7481,7 +7481,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, day& d, { using CT = std::chrono::seconds; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.day().ok()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7497,7 +7497,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, weekday& wd { using CT = std::chrono::seconds; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.wd.ok()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7513,7 +7513,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, year_month& { using CT = std::chrono::seconds; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.month().ok()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7529,7 +7529,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, month_day& { using CT = std::chrono::seconds; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.month().ok() || !fds.ymd.day().ok()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7545,7 +7545,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, { using CT = std::chrono::seconds; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.ok()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7565,7 +7565,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, auto offptr = offset ? offset : &offset_local; fields fds{}; fds.has_tod = true; - gul17::date::from_stream(is, fmt, fds, abbrev, offptr); + GULNS::date::from_stream(is, fmt, fds, abbrev, offptr); if (!fds.ymd.ok() || !fds.tod.in_conventional_range()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7583,7 +7583,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, using detail::round_i; fields fds{}; fds.has_tod = true; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.ok() || !fds.tod.in_conventional_range()) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7602,7 +7602,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, using CT = typename std::common_type::type; using detail::round_i; fields fds{}; - gul17::date::from_stream(is, fmt, fds, abbrev, offset); + GULNS::date::from_stream(is, fmt, fds, abbrev, offset); if (!fds.has_tod) is.setstate(std::ios::failbit); if (!is.fail()) @@ -7653,13 +7653,13 @@ std::basic_istream& operator>>(std::basic_istream& is, const parse_manip& x) { - return gul17::date::from_stream(is, x.format_.c_str(), x.tp_, x.abbrev_, x.offset_); + return GULNS::date::from_stream(is, x.format_.c_str(), x.tp_, x.abbrev_, x.offset_); } template inline auto parse(const std::basic_string& format, Parsable& tp) - -> decltype(gul17::date::from_stream(std::declval&>(), + -> decltype(GULNS::date::from_stream(std::declval&>(), format.c_str(), tp), parse_manip{format, tp}) { @@ -7670,7 +7670,7 @@ template inline auto parse(const std::basic_string& format, Parsable& tp, std::basic_string& abbrev) - -> decltype(gul17::date::from_stream(std::declval&>(), + -> decltype(GULNS::date::from_stream(std::declval&>(), format.c_str(), tp, &abbrev), parse_manip{format, tp, &abbrev}) { @@ -7681,7 +7681,7 @@ template inline auto parse(const std::basic_string& format, Parsable& tp, std::chrono::minutes& offset) - -> decltype(gul17::date::from_stream(std::declval&>(), + -> decltype(GULNS::date::from_stream(std::declval&>(), format.c_str(), tp, std::declval*>(), &offset), @@ -7694,7 +7694,7 @@ template inline auto parse(const std::basic_string& format, Parsable& tp, std::basic_string& abbrev, std::chrono::minutes& offset) - -> decltype(gul17::date::from_stream(std::declval&>(), + -> decltype(GULNS::date::from_stream(std::declval&>(), format.c_str(), tp, &abbrev, &offset), parse_manip{format, tp, &abbrev, &offset}) { @@ -7706,7 +7706,7 @@ parse(const std::basic_string& format, Parsable& tp, template inline auto parse(const CharT* format, Parsable& tp) - -> decltype(gul17::date::from_stream(std::declval&>(), format, tp), + -> decltype(GULNS::date::from_stream(std::declval&>(), format, tp), parse_manip{format, tp}) { return {format, tp}; @@ -7715,7 +7715,7 @@ parse(const CharT* format, Parsable& tp) template inline auto parse(const CharT* format, Parsable& tp, std::basic_string& abbrev) - -> decltype(gul17::date::from_stream(std::declval&>(), format, + -> decltype(GULNS::date::from_stream(std::declval&>(), format, tp, &abbrev), parse_manip{format, tp, &abbrev}) { @@ -7725,7 +7725,7 @@ parse(const CharT* format, Parsable& tp, std::basic_string template inline auto parse(const CharT* format, Parsable& tp, std::chrono::minutes& offset) - -> decltype(gul17::date::from_stream(std::declval&>(), format, + -> decltype(GULNS::date::from_stream(std::declval&>(), format, tp, std::declval*>(), &offset), parse_manip{format, tp, nullptr, &offset}) { @@ -7736,7 +7736,7 @@ template inline auto parse(const CharT* format, Parsable& tp, std::basic_string& abbrev, std::chrono::minutes& offset) - -> decltype(gul17::date::from_stream(std::declval&>(), format, + -> decltype(GULNS::date::from_stream(std::declval&>(), format, tp, &abbrev, &offset), parse_manip{format, tp, &abbrev, &offset}) { @@ -7756,7 +7756,7 @@ operator<<(std::basic_ostream& os, } } // namespace date -} // namespace gul17 +} // namespace GULNS #ifdef _MSC_VER # pragma warning(pop) @@ -7768,4 +7768,4 @@ operator<<(std::basic_ostream& os, /// \endcond -#endif // GUL17_DATE_H_ +#endif // GUL20_DATE_H_ diff --git a/include/gul17/escape.h b/include/gul20/escape.h similarity index 90% rename from include/gul17/escape.h rename to include/gul20/escape.h index ef7f9d0..2a92213 100644 --- a/include/gul17/escape.h +++ b/include/gul20/escape.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 31 August 2018 * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,18 +20,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_ESCAPE_H_ -#define GUL17_ESCAPE_H_ +#ifndef GUL20_ESCAPE_H_ +#define GUL20_ESCAPE_H_ #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup escape_h gul17/escape.h + * \addtogroup escape_h gul20/escape.h * \brief Escaping and unescaping special characters in strings. * @{ */ @@ -76,7 +76,7 @@ std::string escape(std::string_view in); /** * Evaluate a string with escaped characters to get the original string back. - * Does only know the escape sequences used by gul17::escape() and can be + * Does only know the escape sequences used by GULNS::escape() and can be * used as in inverse function. * * \param in The string with escape sequences @@ -90,7 +90,7 @@ std::string unescape(std::string_view in); /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/expected.h b/include/gul20/expected.h similarity index 97% rename from include/gul17/expected.h rename to include/gul20/expected.h index 45d7c7d..d2e8847 100644 --- a/include/gul17/expected.h +++ b/include/gul20/expected.h @@ -1,12 +1,12 @@ /** * \file expected.h * \author Sy Brand, \ref contributors - * \brief Provides a gul17::expected that implements the main functionality of C++23's + * \brief Provides a GULNS::expected that implements the main functionality of C++23's * std::expected. * * \copyright * Written in 2017 by Sy Brand (tartanllama@gmail.com, @TartanLlama) - * Modifications for GUL17 in 2023-2025 by Lars Fröhlich + * Modifications for GUL20 in 2023-2025 by Lars Fröhlich * * This file is based on version 1.1.0 of Sy Brand's expected.h header from * https://github.com/TartanLlama/expected @@ -22,8 +22,8 @@ * . */ -#ifndef GUL17_EXPECTED_H_ -#define GUL17_EXPECTED_H_ +#ifndef GUL20_EXPECTED_H_ +#define GUL20_EXPECTED_H_ #include #include @@ -32,18 +32,18 @@ #include #include -#include "gul17/traits.h" +#include "gul20/traits.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup expected_h gul17/expected.h + * \addtogroup expected_h gul20/expected.h * \brief Backport of std::expected from C++23. * @{ */ /** - * The exception thrown by gul17::expected if value() is called, but no value is present. + * The exception thrown by GULNS::expected if value() is called, but no value is present. * * This exception contains the "unexpected" or "error" value that was stored in the * object instead of the "expected" one. It can be accessed via the error() member @@ -82,7 +82,7 @@ class bad_expected_access; * \endcode * * \note - * The GUL17 version is an adaptation of Sy Brand's implementation (see \ref expected.h) + * The GUL20 version is an adaptation of Sy Brand's implementation (see \ref expected.h) * and should behave like * [std::expected](https://en.cppreference.com/w/cpp/utility/expected) from C++23 for * most use cases. @@ -103,12 +103,12 @@ class unexpected; /// \cond HIDE_SYMBOLS #if defined(__EXCEPTIONS) || defined(_CPPUNWIND) -#define GUL17_EXPECTED_EXCEPTIONS_ENABLED +#define GUL20_EXPECTED_EXCEPTIONS_ENABLED #endif #if (defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__)) -#ifndef GUL17_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX -#define GUL17_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX +#ifndef GUL20_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX +#define GUL20_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX namespace detail { template struct is_trivially_copy_constructible @@ -120,18 +120,18 @@ struct is_trivially_copy_constructible> : std::false_type {}; } // namespace detail #endif -#define GUL17_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ - gul17::detail::is_trivially_copy_constructible -#define GUL17_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \ +#define GUL20_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ + GULNS::detail::is_trivially_copy_constructible +#define GUL20_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \ std::is_trivially_copy_assignable -#define GUL17_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \ +#define GUL20_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \ std::is_trivially_destructible #else -#define GUL17_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ +#define GUL20_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ std::is_trivially_copy_constructible -#define GUL17_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \ +#define GUL20_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \ std::is_trivially_copy_assignable -#define GUL17_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \ +#define GUL20_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \ std::is_trivially_destructible #endif @@ -210,7 +210,7 @@ static constexpr unexpect_t unexpect{}; namespace detail { template [[noreturn]] constexpr void throw_exception(E &&e) { -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED throw std::forward(e); #else (void)e; @@ -285,7 +285,7 @@ struct is_nothrow_swappable (!decltype(detail::swap_adl_tests::uses_std(0))::value && detail::swap_adl_tests::is_adl_swap_noexcept::value))> {}; -// Trait for checking if a type is a gul17::expected +// Trait for checking if a type is a GULNS::expected template struct is_expected_impl : std::false_type {}; template struct is_expected_impl> : std::true_type {}; @@ -607,7 +607,7 @@ struct expected_operations_base : expected_storage_base { this->m_has_val = false; } -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED // These assign overloads ensure that the most efficient assignment // implementation is used while maintaining the strong exception guarantee. @@ -657,7 +657,7 @@ struct expected_operations_base : expected_storage_base { auto tmp = std::move(geterr()); geterr().~unexpected(); -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED try { construct(rhs.get()); } catch (...) { @@ -692,7 +692,7 @@ struct expected_operations_base : expected_storage_base { if (!this->m_has_val && rhs.m_has_val) { auto tmp = std::move(geterr()); geterr().~unexpected(); -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED try { construct(std::move(rhs).get()); } catch (...) { @@ -823,8 +823,8 @@ struct expected_operations_base : expected_storage_base { // This class manages conditionally having a trivial copy constructor // This specialization is for when T and E are trivially copy constructible template :: - value &&GUL17_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value> + bool = is_void_or:: + value &&GUL20_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value> struct expected_copy_base : expected_operations_base { using expected_operations_base::expected_operations_base; }; @@ -880,12 +880,12 @@ struct expected_move_base : expected_copy_base { // This class manages conditionally having a trivial copy assignment operator template >::value - &&GUL17_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value - &&GUL17_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value - &&GUL17_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value> + T, std::conjunction>::value + &&GUL20_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(E)::value + &&GUL20_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(E)::value + &&GUL20_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(E)::value> struct expected_copy_assign_base : expected_move_base { using expected_move_base::expected_move_base; }; @@ -1437,7 +1437,7 @@ class expected : private detail::expected_move_assign_base, auto tmp = std::move(err()); err().~unexpected(); -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED try { ::new (valptr()) T(std::forward(v)); this->m_has_val = true; @@ -1506,7 +1506,7 @@ class expected : private detail::expected_move_assign_base, auto tmp = std::move(err()); err().~unexpected(); -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED try { ::new (valptr()) T(std::forward(args)...); this->m_has_val = true; @@ -1546,7 +1546,7 @@ class expected : private detail::expected_move_assign_base, auto tmp = std::move(err()); err().~unexpected(); -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED try { ::new (valptr()) T(il, std::forward(args)...); this->m_has_val = true; @@ -1607,7 +1607,7 @@ class expected : private detail::expected_move_assign_base, move_constructing_e_can_throw) { auto temp = std::move(val()); val().~T(); -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED try { ::new (errptr()) unexpected_type(std::move(rhs.err())); rhs.err().~unexpected_type(); @@ -1630,7 +1630,7 @@ class expected : private detail::expected_move_assign_base, e_is_nothrow_move_constructible) { auto temp = std::move(rhs.err()); rhs.err().~unexpected_type(); -#ifdef GUL17_EXPECTED_EXCEPTIONS_ENABLED +#ifdef GUL20_EXPECTED_EXCEPTIONS_ENABLED try { ::new (rhs.valptr()) T(std::move(val())); val().~T(); @@ -1999,6 +1999,6 @@ void swap(expected &lhs, /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/finalizer.h b/include/gul20/finalizer.h similarity index 92% rename from include/gul17/finalizer.h rename to include/gul20/finalizer.h index e394532..1510320 100644 --- a/include/gul17/finalizer.h +++ b/include/gul20/finalizer.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 23 October 2018 * - * \copyright Copyright 2018-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,18 +20,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_FINALIZER_H_ -#define GUL17_FINALIZER_H_ +#ifndef GUL20_FINALIZER_H_ +#define GUL20_FINALIZER_H_ #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup finalizer_h gul17/finalizer.h + * \addtogroup finalizer_h gul20/finalizer.h * \brief Executing some clean-up code when leaving a scope. * @{ */ @@ -53,12 +53,12 @@ namespace gul17 { * \code * #include * #include - * #include + * #include * - * using gul17::finally; - * using gul17::sleep; - * using gul17::tic; - * using gul17::toc; + * using GULNS::finally; + * using GULNS::sleep; + * using GULNS::tic; + * using GULNS::toc; * * void foo() { * auto _ = finally([start = tic()] { @@ -79,9 +79,9 @@ namespace gul17 { * \code * #include * #include - * #include + * #include * - * using gul17::finally; + * using GULNS::finally; * * std::string bar(float some_float) { * char* buffer = new char[100]; @@ -172,7 +172,7 @@ FinalAction> finally(F&& f) noexcept { /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/gcd_lcm.h b/include/gul20/gcd_lcm.h similarity index 84% rename from include/gul17/gcd_lcm.h rename to include/gul20/gcd_lcm.h index 00ff77d..0a569ea 100644 --- a/include/gul17/gcd_lcm.h +++ b/include/gul20/gcd_lcm.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 5 August 2022 * - * \copyright Copyright 2022-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2022-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,18 +20,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_GCD_LCM_H_ -#define GUL17_GCD_LCM_H_ +#ifndef GUL20_GCD_LCM_H_ +#define GUL20_GCD_LCM_H_ #include -#include "gul17/internal.h" -#include "gul17/num_util.h" +#include "gul20/internal.h" +#include "gul20/num_util.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup gcd_lcm_h gul17/gcd_lcm.h + * \addtogroup gcd_lcm_h gul20/gcd_lcm.h * \brief Greatest common divisor and least common multiple. * @{ */ @@ -52,7 +52,7 @@ namespace gul17 { * type, the result is undefined. * * \note - * Unlike `std::gcd()` from C++17, the GUL17 version cannot be used with integers of + * Unlike `std::gcd()` from C++17, the GUL20 version cannot be used with integers of * different signedness. This avoids undefined behavior when mixing unsigned integers with * negative signed values: * \code @@ -60,8 +60,8 @@ namespace gul17 { * // representation in that type * auto bad_result = std::gcd(10u, -5); * - * // GUL17 gcd(): Does not compile - * auto static_assertion_failure = gul17::gcd(10u, -5); + * // GUL20 gcd(): Does not compile + * auto static_assertion_failure = GULNS::gcd(10u, -5); * \endcode * * \since GUL version 2.7 @@ -78,8 +78,8 @@ gcd(IntTypeA a, IntTypeB b) using CommonType = std::common_type_t; - auto c = gul17::abs(static_cast(a)); - auto d = gul17::abs(static_cast(b)); + auto c = GULNS::abs(static_cast(a)); + auto d = GULNS::abs(static_cast(b)); while (d != 0) { @@ -106,7 +106,7 @@ gcd(IntTypeA a, IntTypeB b) * type, the result is undefined. * * \note - * Unlike `std::lcm()` from C++17, the GUL17 version cannot be used with integers of + * Unlike `std::lcm()` from C++17, the GUL20 version cannot be used with integers of * different signedness. This avoids undefined behavior when mixing unsigned integers with * negative signed values: * \code @@ -114,8 +114,8 @@ gcd(IntTypeA a, IntTypeB b) * // representation in that type * auto bad_result = std::lcm(10u, -5); * - * // GUL17 lcm(): Does not compile - * auto static_assertion_failure = gul17::lcm(10u, -5); + * // GUL20 lcm(): Does not compile + * auto static_assertion_failure = GULNS::lcm(10u, -5); * \endcode * * \since GUL version 2.7 @@ -135,11 +135,11 @@ lcm(IntTypeA a, IntTypeB b) if (a == 0 && b == 0) return CommonType{ 0 }; - return static_cast(gul17::abs((a / gcd(a, b)) * b)); + return static_cast(GULNS::abs((a / gcd(a, b)) * b)); } /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/gul.h b/include/gul20/gul.h similarity index 50% rename from include/gul17/gul.h rename to include/gul20/gul.h index e8e2b58..3b6cd57 100644 --- a/include/gul17/gul.h +++ b/include/gul20/gul.h @@ -4,7 +4,7 @@ * \date Created on August 24, 2018 * \brief Main include file for the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,50 +20,48 @@ * along with this program. If not, see . */ -#ifndef GUL17_GUL_H_ -#define GUL17_GUL_H_ +#ifndef GUL20_GUL_H_ +#define GUL20_GUL_H_ /** - * \defgroup gul_h gul17/gul.h - * \brief All-in-one include file for GUL17. + * \defgroup gul_h gul20/gul.h + * \brief All-in-one include file for GUL20. * \details * This file includes almost all other headers provided by the library. One specific file * is excluded, however: *
    - *
  • `gul17/date.h`: Howard Hinnant's header for calendar date functionality
  • + *
  • `gul20/date.h`: Howard Hinnant's header for calendar date functionality
  • *
* `date.h` is excluded chiefly because of its negative impact on compile times. Just * include it directly where needed. */ -#include "gul17/bit_manip.h" -#include "gul17/case_ascii.h" -#include "gul17/cat.h" -// #include "gul17/catch.h" not included because it is only useful for unit tests -// #include "gul17/date.h" not included by default to reduce compile times -#include "gul17/escape.h" -#include "gul17/expected.h" -#include "gul17/finalizer.h" -#include "gul17/gcd_lcm.h" -#include "gul17/hexdump.h" -#include "gul17/join_split.h" -#include "gul17/num_util.h" -#include "gul17/OverloadSet.h" -#include "gul17/replace.h" -#include "gul17/SlidingBuffer.h" -#include "gul17/SmallVector.h" -#include "gul17/span.h" -#include "gul17/statistics.h" -#include "gul17/string_util.h" -#include "gul17/substring_checks.h" -#include "gul17/ThreadPool.h" -#include "gul17/time_util.h" -#include "gul17/to_number.h" -#include "gul17/tokenize.h" -#include "gul17/traits.h" -#include "gul17/Trigger.h" -#include "gul17/trim.h" -#include "gul17/type_name.h" -#include "gul17/version.h" +#include "gul20/bit_manip.h" +#include "gul20/case_ascii.h" +#include "gul20/cat.h" +// #include "gul20/date.h" not included by default to reduce compile times +#include "gul20/escape.h" +#include "gul20/expected.h" +#include "gul20/finalizer.h" +#include "gul20/gcd_lcm.h" +#include "gul20/hexdump.h" +#include "gul20/join_split.h" +#include "gul20/num_util.h" +#include "gul20/OverloadSet.h" +#include "gul20/replace.h" +#include "gul20/SlidingBuffer.h" +#include "gul20/SmallVector.h" +#include "gul20/statistics.h" +#include "gul20/string_util.h" +#include "gul20/substring_checks.h" +#include "gul20/ThreadPool.h" +#include "gul20/time_util.h" +#include "gul20/to_number.h" +#include "gul20/tokenize.h" +#include "gul20/traits.h" +#include "gul20/Trigger.h" +#include "gul20/trim.h" +#include "gul20/type_name.h" +#include "gul20/version.h" #endif diff --git a/include/gul17/hexdump.h b/include/gul20/hexdump.h similarity index 96% rename from include/gul17/hexdump.h rename to include/gul20/hexdump.h index 75b24d6..0408890 100644 --- a/include/gul17/hexdump.h +++ b/include/gul20/hexdump.h @@ -4,7 +4,7 @@ * \date Created on September 25, 2018 * \brief Declaration of the hexdump() functions and associated types. * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GUL17_HEXDUMP_H_ -#define GUL17_HEXDUMP_H_ +#ifndef GUL20_HEXDUMP_H_ +#define GUL20_HEXDUMP_H_ #include #include @@ -29,7 +29,7 @@ #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" ////// Overview of the prototypes contained in here, but without template specifications: // @@ -46,10 +46,10 @@ // ////// -namespace gul17 { +namespace GULNS { /** - * \addtogroup hexdump_h gul17/hexdump.h + * \addtogroup hexdump_h gul20/hexdump.h * \brief Hexadecimal dump of data. * @{ */ @@ -192,7 +192,7 @@ StreamT& hexdump_stream(StreamT& dest, const IteratorT& begin, const IteratorT& * * \code * std::string x = "test\nthe Ä west!\t\r\n"; - * std::string str = gul17::hexdump(x.begin(), x.end(), "debug -> "); + * std::string str = GULNS::hexdump(x.begin(), x.end(), "debug -> "); * std::cerr << str; * \endcode \verbatim @@ -202,7 +202,7 @@ deBug -> 000000: 74 65 73 74 0a 74 68 65 20 c3 84 20 77 65 73 74 test.the .. we * * \code * std::array ar = {{ 0, 1, 5, 2, -0x300fffff, 2, 5, 1999 }}; - * std::string str = gul17::hexdump(begin(ar), end(ar)); + * std::string str = GULNS::hexdump(begin(ar), end(ar)); * std::cout << str; * \endcode \verbatim @@ -384,8 +384,8 @@ class HexdumpParameterForward { * via operator<<. This means that the following two lines produce the exact same output, * but the stream version uses less resources: * \code - * std::cout << gul17::hexdump_stream(x.begin(), x.end()) << "\n"; // good - * std::cout << gul17::hexdump(x.begin(), x.end()) << "\n"; // also good, but allocates a temporary string + * std::cout << GULNS::hexdump_stream(x.begin(), x.end()) << "\n"; // good + * std::cout << GULNS::hexdump(x.begin(), x.end()) << "\n"; // also good, but allocates a temporary string * \endcode * * The elements of the data range must be of integral type. They are dumped as unsigned @@ -396,7 +396,7 @@ class HexdumpParameterForward { * * \code * std::string x = "test\nthe Ä west!\t\r\n"; - * std::cerr << gul17::hexdump_stream(x.begin(), x.end(), "debug -> "); + * std::cerr << GULNS::hexdump_stream(x.begin(), x.end(), "debug -> "); * \endcode \verbatim debug -> 000000: 74 65 73 74 0a 74 68 65 20 c3 84 20 77 65 73 74 test.the .. west @@ -405,7 +405,7 @@ debug -> 000000: 74 65 73 74 0a 74 68 65 20 c3 84 20 77 65 73 74 test.the .. we * * \code * std::array ar = {{ 0, 1, 5, 2, -0x300fffff, 2, 5, 1999 }}; - * std::cout << gul17::hexdump_stream(begin(ar), end(ar)); + * std::cout << GULNS::hexdump_stream(begin(ar), end(ar)); * \endcode \verbatim 000000: 00000000 00000001 00000005 00000002 cff00001 00000002 00000005 000007cf @@ -464,7 +464,7 @@ hexdump_stream(ContainerT&& cont, std::string prompt = "") /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/internal.h b/include/gul20/internal.h similarity index 93% rename from include/gul17/internal.h rename to include/gul20/internal.h index 1b1e96a..77148e6 100644 --- a/include/gul17/internal.h +++ b/include/gul20/internal.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 7 Aug 2019 * - * \copyright Copyright 2019-2020 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GUL17_INTERNAL_H_ -#define GUL17_INTERNAL_H_ +#ifndef GUL20_INTERNAL_H_ +#define GUL20_INTERNAL_H_ // For old Visual C++ compilers, including enables the alternative operator // representations "and", "or", and "not". diff --git a/include/gul17/join_split.h b/include/gul20/join_split.h similarity index 98% rename from include/gul17/join_split.h rename to include/gul20/join_split.h index d21f90c..e36079e 100644 --- a/include/gul17/join_split.h +++ b/include/gul20/join_split.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 31 August 2018 * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GUL17_JOIN_SPLIT_H_ -#define GUL17_JOIN_SPLIT_H_ +#ifndef GUL20_JOIN_SPLIT_H_ +#define GUL20_JOIN_SPLIT_H_ #include #include @@ -30,13 +30,13 @@ #include #include -#include "gul17/internal.h" -#include "gul17/string_util.h" +#include "gul20/internal.h" +#include "gul20/string_util.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup join_split_h gul17/join_split.h + * \addtogroup join_split_h gul20/join_split.h * \brief Joining and splitting strings. * @{ */ @@ -94,7 +94,7 @@ namespace gul17 { * assert(parts1[1] == "world"); // string literal with static storage duration * * // Custom container type - * auto parts2 = split>("a--b--c", "--"); + * auto parts2 = split>("a--b--c", "--"); * assert(parts2.size() == 3); * assert(parts2[0] == "a"); * assert(parts2[1] == "b"); @@ -460,7 +460,7 @@ join(const Container& container, std::string_view glue, ConversionFct to_string, /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/meson.build b/include/gul20/meson.build similarity index 98% rename from include/gul17/meson.build rename to include/gul20/meson.build index db7f45e..389f0de 100644 --- a/include/gul17/meson.build +++ b/include/gul20/meson.build @@ -15,7 +15,6 @@ standalone_headers = [ 'replace.h', 'SlidingBuffer.h', 'SmallVector.h', - 'span.h', 'statistics.h', 'string_util.h', 'substring_checks.h', diff --git a/include/gul17/num_util.h b/include/gul20/num_util.h similarity index 95% rename from include/gul17/num_util.h rename to include/gul20/num_util.h index 3a05edf..5fb7c4c 100644 --- a/include/gul17/num_util.h +++ b/include/gul20/num_util.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 7 Feb 2019 * - * \copyright Copyright 2019-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,20 +20,20 @@ * along with this program. If not, see . */ -#ifndef GUL17_NUM_UTIL_H_ -#define GUL17_NUM_UTIL_H_ +#ifndef GUL20_NUM_UTIL_H_ +#define GUL20_NUM_UTIL_H_ #include #include #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup num_util_h gul17/num_util.h + * \addtogroup num_util_h gul20/num_util.h * \brief Numerical utility functions. * @{ */ @@ -96,10 +96,10 @@ template> bool within_orders(const NumT a, const NumT b, const OrderT orders) noexcept(false) { // std::pow() is not noexcept, which might or might not be true - auto difference = gul17::abs(a - b); + auto difference = GULNS::abs(a - b); if (difference == NumT{ 0 }) return true; - auto maximum = std::max(gul17::abs(a), gul17::abs(b)); + auto maximum = std::max(GULNS::abs(a), GULNS::abs(b)); auto limit = maximum / std::pow(static_cast>(10.0), orders); return difference < limit; } @@ -117,7 +117,7 @@ bool within_orders(const NumT a, const NumT b, const OrderT orders) noexcept(fal */ template bool within_abs(NumT a, NumT b, NumT tol) noexcept { - tol = gul17::abs(tol); // Negative diff does not make sense + tol = GULNS::abs(tol); // Negative diff does not make sense bool ret{}; if (a > b) { if (std::is_floating_point::value) @@ -242,7 +242,7 @@ constexpr const NumT& clamp(const NumT& v, const NumT& lo, const NumT& hi, Compa /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/replace.h b/include/gul20/replace.h similarity index 90% rename from include/gul17/replace.h rename to include/gul20/replace.h index 9ec7d28..b817761 100644 --- a/include/gul17/replace.h +++ b/include/gul20/replace.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 31 August 2018 * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,18 +20,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_REPLACE_H_ -#define GUL17_REPLACE_H_ +#ifndef GUL20_REPLACE_H_ +#define GUL20_REPLACE_H_ #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup replace_h gul17/replace.h + * \addtogroup replace_h gul20/replace.h * \brief Replacing all occurrences of a string within another string. * @{ */ @@ -66,7 +66,7 @@ std::string& replace_inplace(std::string& haystack, std::string_view needle, std /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/statistics.h b/include/gul20/statistics.h similarity index 99% rename from include/gul17/statistics.h rename to include/gul20/statistics.h index 0dcff4d..e7424c8 100644 --- a/include/gul17/statistics.h +++ b/include/gul20/statistics.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 7 February 2019 * - * \copyright Copyright 2019-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GUL17_STATISTICS_H_ -#define GUL17_STATISTICS_H_ +#ifndef GUL20_STATISTICS_H_ +#define GUL20_STATISTICS_H_ #include #include @@ -30,13 +30,13 @@ #include #include -#include "gul17/internal.h" -#include "gul17/traits.h" +#include "gul20/internal.h" +#include "gul20/traits.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup statistics_h gul17/statistics.h + * \addtogroup statistics_h gul20/statistics.h * \brief Statistical utility functions and classes. * @{ */ @@ -836,7 +836,7 @@ auto accumulate(IteratorT const& begin, IteratorT const& end, OpClosure op, return accumulate(make_view(begin, end), op, accessor); } -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/string_util.h b/include/gul20/string_util.h similarity index 97% rename from include/gul17/string_util.h rename to include/gul20/string_util.h index 8aab6d8..2be6797 100644 --- a/include/gul17/string_util.h +++ b/include/gul20/string_util.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 31 August 2018 * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,21 +20,21 @@ * along with this program. If not, see . */ -#ifndef GUL17_STRING_UTIL_H_ -#define GUL17_STRING_UTIL_H_ +#ifndef GUL20_STRING_UTIL_H_ +#define GUL20_STRING_UTIL_H_ #include #include #include #include -#include "gul17/internal.h" -#include "gul17/traits.h" +#include "gul20/internal.h" +#include "gul20/traits.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup string_util_h gul17/string_util.h + * \addtogroup string_util_h gul20/string_util.h * \brief Various string utility functions. * @{ */ @@ -211,7 +211,7 @@ hex_string(const Integer (&array)[num_elements], std::string_view separator = "" * \param separator A string that is inserted between the elements to separate them * visually (empty by default) * - * \tparam Container must be a gul17::IsContainerLike class + * \tparam Container must be a GULNS::IsContainerLike class * * \since GUL version 2.6 */ @@ -362,7 +362,7 @@ std::string_view safe_string_view(const char* char_ptr, std::size_t length); /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/substring_checks.h b/include/gul20/substring_checks.h similarity index 97% rename from include/gul17/substring_checks.h rename to include/gul20/substring_checks.h index f0df773..4e41473 100644 --- a/include/gul17/substring_checks.h +++ b/include/gul20/substring_checks.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 26 November 2018 * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,18 +20,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_SUBSTRING_CHECKS_H_ -#define GUL17_SUBSTRING_CHECKS_H_ +#ifndef GUL20_SUBSTRING_CHECKS_H_ +#define GUL20_SUBSTRING_CHECKS_H_ #include -#include "gul17/case_ascii.h" -#include "gul17/internal.h" +#include "gul20/case_ascii.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup substring_checks_h gul17/substring_checks.h + * \addtogroup substring_checks_h gul20/substring_checks.h * \brief Checking whether a string contains, ends with, or starts with another string. * @{ */ @@ -344,7 +344,7 @@ constexpr inline bool starts_with_nocase(std::string_view str, char c) noexcept /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/time_util.h b/include/gul20/time_util.h similarity index 96% rename from include/gul17/time_util.h rename to include/gul20/time_util.h index d4eb96e..65ea395 100644 --- a/include/gul17/time_util.h +++ b/include/gul20/time_util.h @@ -4,7 +4,7 @@ * \date Created on September 7, 2018 * \brief Declaration of time related functions for the General Utility Library. * - * \copyright Copyright 2018-2023 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,19 +20,19 @@ * along with this program. If not, see . */ -#ifndef GUL17_TIME_UTIL_H_ -#define GUL17_TIME_UTIL_H_ +#ifndef GUL20_TIME_UTIL_H_ +#define GUL20_TIME_UTIL_H_ #include #include -#include "gul17/internal.h" -#include "gul17/Trigger.h" +#include "gul20/internal.h" +#include "gul20/Trigger.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup time_util_h gul17/time_util.h + * \addtogroup time_util_h gul20/time_util.h * \brief Time-related functions. * @{ */ @@ -186,6 +186,6 @@ inline bool sleep(double seconds) /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/to_number.h b/include/gul20/to_number.h similarity index 97% rename from include/gul17/to_number.h rename to include/gul20/to_number.h index f1d014d..4dfcf21 100644 --- a/include/gul17/to_number.h +++ b/include/gul20/to_number.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 19 July 2019 * - * \copyright Copyright 2019-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GUL17_TO_NUMBER_H_ -#define GUL17_TO_NUMBER_H_ +#ifndef GUL20_TO_NUMBER_H_ +#define GUL20_TO_NUMBER_H_ #include #include @@ -33,13 +33,13 @@ #include #include -#include "gul17/internal.h" -#include "gul17/substring_checks.h" +#include "gul20/internal.h" +#include "gul20/substring_checks.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup to_number_h gul17/to_number.h + * \addtogroup to_number_h gul20/to_number.h * \brief Converting strings to numbers. * @{ */ @@ -239,16 +239,16 @@ constexpr inline ParseInfNanResult parse_inf_nan(std::string_view st if (strlength == 0) return { true, {} }; - if (gul17::starts_with_nocase(str, "inf")) { + if (GULNS::starts_with_nocase(str, "inf")) { if (strlength == 3 /* strlen("inf") */ ) return { true, std::make_optional(std::numeric_limits::infinity()) }; if (strlength == 8 /* strlen("infinity") */ - and gul17::starts_with_nocase(str.substr(3), "inity")) + and GULNS::starts_with_nocase(str.substr(3), "inity")) return { true, std::make_optional(std::numeric_limits::infinity()) }; return { true, {} }; } - if (gul17::starts_with_nocase(str, "nan")) { + if (GULNS::starts_with_nocase(str, "nan")) { if (strlength == 3 /* strlen("nan") */ ) return { true, std::make_optional(std::numeric_limits::quiet_NaN()) }; if (strlength < 5 /* strlen("nan()") */ or str[3] != '(' or str.back() != ')') @@ -385,7 +385,7 @@ constexpr inline std::optional to_unsigned_float(std::string_view st * \returns an std::optional that contains std::strtold()'s return value (include HUGE_VAL). * Parsing failure (including number end before string end) is returned by std::nullopt. * - * \note This function is used as fallback solution if we can not use gul17::to_unsigned_float() + * \note This function is used as fallback solution if we can not use GULNS::to_unsigned_float() * for the desired conversions. This can have two reasons: * - The internally used integer type is too small compared to the floating point type. * - On Apple clang 8.0.0 std::pow() is inaccurate. @@ -422,7 +422,7 @@ inline std::optional strtold_wrapper(std::string_view str) noexcept * an std::optional integer or floating-point number. * * \code - * std::optional result = gul17::to_number("42"); + * std::optional result = GULNS::to_number("42"); * * if (result.has_value()) * std::cout << "The answer is " << result.value() << ".\n"; @@ -594,7 +594,7 @@ constexpr inline std::optional to_number(std::string_view str) noexc /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/tokenize.h b/include/gul20/tokenize.h similarity index 92% rename from include/gul17/tokenize.h rename to include/gul20/tokenize.h index 992520f..8434c41 100644 --- a/include/gul17/tokenize.h +++ b/include/gul20/tokenize.h @@ -4,7 +4,7 @@ * \date Created on September 3, 2018 * \brief Implementation of tokenize(), tokenize_sv(). * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,20 +20,20 @@ * along with this program. If not, see . */ -#ifndef GUL17_TOKENIZE_H_ -#define GUL17_TOKENIZE_H_ +#ifndef GUL20_TOKENIZE_H_ +#define GUL20_TOKENIZE_H_ #include #include #include -#include "gul17/internal.h" -#include "gul17/string_util.h" +#include "gul20/internal.h" +#include "gul20/string_util.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup tokenize_h gul17/tokenize.h + * \addtogroup tokenize_h gul20/tokenize.h * \brief Split a string into substrings. * @{ */ @@ -81,7 +81,7 @@ namespace gul17 { * assert(parts1[1] == "world"); * * // Use a different container that provides emplace_back() - * auto parts2 = tokenize>("a-b-c", "-"); + * auto parts2 = tokenize>("a-b-c", "-"); * assert(parts2.size() == 3); * assert(parts2[0] == "a"); * assert(parts2[1] == "b"); @@ -104,7 +104,7 @@ namespace gul17 { * assert(words.size() == 3); // Might fail or succeed depending on the encoding * ``` * - * \see gul17::tokenize_sv() returns a vector by default, gul17::split() uses + * \see GULNS::tokenize_sv() returns a vector by default, GULNS::split() uses * a different approach to string splitting. * * \since GUL version 2.5, the return type of split() can be specified as a template @@ -158,7 +158,7 @@ tokenize(std::string_view str, std::string_view delimiters = default_whitespace_ * assert(tokens[1] == "world"); * \endcode * - * \see gul17::tokenize() returns a vector by default, gul17::split() uses a + * \see GULNS::tokenize() returns a vector by default, GULNS::split() uses a * different approach to string splitting. * * \since GUL version 2.5, the return type of tokenize_sv() can be specified as a template @@ -176,6 +176,6 @@ tokenize_sv(std::string_view str, std::string_view delimiters = default_whitespa /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/traits.h b/include/gul20/traits.h similarity index 64% rename from include/gul17/traits.h rename to include/gul20/traits.h index 44d0fb0..6a94066 100644 --- a/include/gul17/traits.h +++ b/include/gul20/traits.h @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 20 August 2021 * - * \copyright Copyright 2021-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2021-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -21,19 +21,18 @@ */ -#ifndef GUL17_TRAITS_H_ -#define GUL17_TRAITS_H_ +#ifndef GUL20_TRAITS_H_ +#define GUL20_TRAITS_H_ -#include // for std::invoke on C++17 compilers #include #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup traits_h gul17/traits.h + * \addtogroup traits_h gul20/traits.h * \brief Type traits and helpers for metaprogramming. * @{ */ @@ -65,33 +64,9 @@ struct IsContainerLike > : std::true_type { }; -/** - * A template metafunction that removes const, volatile, and reference qualifiers from a - * type. The stripped type is available in the member typedef \c type. - * - * This is a substitute for C++20's - * [std::remove_cvref](https://en.cppreference.com/w/cpp/types/remove_cvref). - * - * \since GUL version 2.9 - */ -template -using remove_cvref = typename std::remove_cv>; - -/** - * A template metafunction that removes const, volatile, and reference qualifiers from a - * type. - * - * This is a substitute for C++20's - * [std::remove_cvref_t](https://en.cppreference.com/w/cpp/types/remove_cvref_t). - * - * \since GUL version 2.9 - */ -template -using remove_cvref_t = typename remove_cvref::type; - /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/trim.h b/include/gul20/trim.h similarity index 96% rename from include/gul17/trim.h rename to include/gul20/trim.h index 11f8cb6..cc8fd05 100644 --- a/include/gul17/trim.h +++ b/include/gul20/trim.h @@ -5,7 +5,7 @@ * \brief Declarations of trim(), trim_left(), trim_right(), trim_sv(), trim_left_sv(), * and trim_right_sv(). * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -21,18 +21,18 @@ * along with this program. If not, see . */ -#ifndef GUL17_TRIM_H_ -#define GUL17_TRIM_H_ +#ifndef GUL20_TRIM_H_ +#define GUL20_TRIM_H_ #include -#include "gul17/internal.h" -#include "gul17/string_util.h" +#include "gul20/internal.h" +#include "gul20/string_util.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup trim_h gul17/trim.h + * \addtogroup trim_h gul20/trim.h * \brief Trimming whitespace from strings. * @{ */ @@ -161,7 +161,7 @@ std::string_view trim_right_sv(std::string_view str, std::string_view ws_chars = /// @} -} // namespace gul17 +} // namespace GULNS /** diff --git a/include/gul17/type_name.h b/include/gul20/type_name.h similarity index 88% rename from include/gul17/type_name.h rename to include/gul20/type_name.h index ac0972e..c3c3924 100644 --- a/include/gul17/type_name.h +++ b/include/gul20/type_name.h @@ -4,7 +4,7 @@ * \date Created on April 11, 2019 * \brief Definition of type_name() * - * \copyright Copyright 2019-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -23,17 +23,17 @@ * His code has been inspired by posts of Jamboree at Stackoverflow. */ -#ifndef GUL17_TYPE_NAME_H_ -#define GUL17_TYPE_NAME_H_ +#ifndef GUL20_TYPE_NAME_H_ +#define GUL20_TYPE_NAME_H_ #include -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** - * \addtogroup type_name_h gul17/type_name.h + * \addtogroup type_name_h gul20/type_name.h * \brief Generating human-readable descriptions for types. * @{ */ @@ -51,7 +51,7 @@ namespace gul17 { * A using example: * \code * auto t = some_type_or_another{ }; - * gul17::FailToInstantiate{}; + * GULNS::FailToInstantiate{}; * \endcode * A more realistic example for people shying away from ``auto``: * \code @@ -59,7 +59,7 @@ namespace gul17 { * void my_function(T param) * { * // wondering if T is what I expect... - * gul17::FailToInstantiate{}; + * GULNS::FailToInstantiate{}; * } * \endcode */ @@ -81,7 +81,7 @@ class FailToInstantiate; * Use like this: * \code * auto& literal = "test"; - * std::cout << "The type is " << gul17::type_name() << '\n'; + * std::cout << "The type is " << GULNS::type_name() << '\n'; * \endcode * * \tparam T Type that shall be described @@ -107,7 +107,7 @@ constexpr std::string_view type_name() #elif defined(_MSC_VER) // MSVC returns something like "return_type function_name()" auto s = std::string_view{ __FUNCSIG__ }; - auto const start_idx = s.find("gul17::type_name<") + sizeof("gul17::type_name<") - 1; + auto const start_idx = s.find("GULNS::type_name<") + sizeof("GULNS::type_name<") - 1; s.remove_prefix(start_idx); for (auto end_idx = s.length() - 1; end_idx; --end_idx) { @@ -124,7 +124,7 @@ constexpr std::string_view type_name() /// @} -} // namespace gul17 +} // namespace GULNS #endif diff --git a/include/gul17/version.h b/include/gul20/version.h similarity index 83% rename from include/gul17/version.h rename to include/gul20/version.h index 023b9b8..a54fe32 100644 --- a/include/gul17/version.h +++ b/include/gul20/version.h @@ -4,7 +4,7 @@ * \date Created on September 14, 2018 * \brief Provide information about the library version * - * \copyright Copyright 2018-2020 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,12 +20,12 @@ * along with this program. If not, see . */ -#ifndef GUL17_VERSION_H_ -#define GUL17_VERSION_H_ +#ifndef GUL20_VERSION_H_ +#define GUL20_VERSION_H_ -#include "gul17/internal.h" +#include "gul20/internal.h" -namespace gul17 { +namespace GULNS { /** * Holds the version of the library. @@ -33,6 +33,6 @@ namespace gul17 { GUL_EXPORT extern char const* version; -} // namespace gul17 +} // namespace GULNS #endif diff --git a/meson.build b/meson.build index a0267ce..0cdb867 100644 --- a/meson.build +++ b/meson.build @@ -2,9 +2,9 @@ # The version in project() is the Doocs version / package version -project('gul17', 'cpp', +project('gul20', 'cpp', default_options : [ - 'cpp_std=c++17', + 'cpp_std=c++20', 'buildtype=debugoptimized', 'warning_level=3', 'default_library=both', diff --git a/src/ThreadPool.cc b/src/ThreadPool.cc index dd88aac..7e226f4 100644 --- a/src/ThreadPool.cc +++ b/src/ThreadPool.cc @@ -4,7 +4,7 @@ * \date Created on November 6, 2018 * \brief Implementation of the ThreadPool class. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -23,13 +23,13 @@ #include #include -#include -#include -#include +#include +#include +#include #include -namespace gul17 { +namespace GULNS { namespace detail { @@ -279,4 +279,4 @@ void ThreadPool::perform_work(const ThreadPool::ThreadId thread_id) thread_local ThreadPool::ThreadId ThreadPool::thread_id_{ std::numeric_limits::max() }; -} // namespace gul17 +} // namespace GULNS diff --git a/src/Trigger.cc b/src/Trigger.cc index 1ea4fc0..252bd71 100644 --- a/src/Trigger.cc +++ b/src/Trigger.cc @@ -4,7 +4,7 @@ * \brief Implementation of the Trigger class for the General Utility Library. * \date Created on September 21, 2018 * - * \copyright Copyright 2018 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,9 +20,9 @@ * along with this program. If not, see . */ -#include "gul17/Trigger.h" +#include "gul20/Trigger.h" -namespace gul17 { +namespace GULNS { Trigger::~Trigger() noexcept @@ -76,4 +76,4 @@ void Trigger::wait() const } -} // namespace gul17 +} // namespace GULNS diff --git a/src/case_ascii.cc b/src/case_ascii.cc index 48effaf..c226afa 100644 --- a/src/case_ascii.cc +++ b/src/case_ascii.cc @@ -5,7 +5,7 @@ * \authors \ref contributors * \date Created on 28 May 2019 * - * \copyright Copyright 2019 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -21,10 +21,10 @@ * along with this program. If not, see . */ -#include "gul17/case_ascii.h" +#include "gul20/case_ascii.h" -namespace gul17 { +namespace GULNS { std::string lowercase_ascii(std::string_view str) { @@ -64,6 +64,6 @@ std::string &uppercase_ascii_inplace(std::string &str) noexcept return str; } -} // namespace gul17 +} // namespace GULNS /* vim:set expandtab softtabstop=4 tabstop=4 shiftwidth=4 textwidth=90 cindent: */ diff --git a/src/cat.cc b/src/cat.cc index 34381db..148dd2d 100644 --- a/src/cat.cc +++ b/src/cat.cc @@ -4,7 +4,7 @@ * \brief Implementation of cat() for two or more parameters. * \date Created on August 31, 2018 * - * \copyright Copyright 2018-2019 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,9 +20,9 @@ * along with this program. If not, see . */ -#include "gul17/cat.h" +#include "gul20/cat.h" -namespace gul17 { +namespace GULNS { std::string cat(const ConvertingStringView& s1, const ConvertingStringView& s2) @@ -60,4 +60,4 @@ std::string cat(std::initializer_list pieces) return str; } -} // namespace gul17 +} // namespace GULNS diff --git a/src/escape.cc b/src/escape.cc index 4285cea..04fdacd 100644 --- a/src/escape.cc +++ b/src/escape.cc @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 31 August 2018 * - * \copyright Copyright 2018-2021 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -23,12 +23,12 @@ #include #include -#include "gul17/escape.h" -#include "gul17/string_util.h" +#include "gul20/escape.h" +#include "gul20/string_util.h" using namespace std::literals::string_literals; -namespace gul17 { +namespace GULNS { std::string escape(std::string_view in) { @@ -125,6 +125,6 @@ std::string unescape(std::string_view in) return unescaped; } -} // namespace gul17 +} // namespace GULNS // vi:ts=4:sw=4:sts=4:et diff --git a/src/replace.cc b/src/replace.cc index 3f5961a..3f75d4f 100644 --- a/src/replace.cc +++ b/src/replace.cc @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 31 August 2018 * - * \copyright Copyright 2018 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,11 +20,11 @@ * along with this program. If not, see . */ -#include "gul17/replace.h" +#include "gul20/replace.h" using namespace std::literals::string_literals; -namespace gul17 { +namespace GULNS { std::string replace(std::string_view haystack, std::string_view needle, std::string_view hammer) { @@ -65,6 +65,6 @@ std::string& replace_inplace(std::string& haystack, std::string_view needle, std return haystack; } -} // namespace gul17 +} // namespace GULNS /* vim:set expandtab softtabstop=4 tabstop=4 shiftwidth=4 textwidth=90 cindent: */ diff --git a/src/string_util.cc b/src/string_util.cc index 5454c90..1a9e477 100644 --- a/src/string_util.cc +++ b/src/string_util.cc @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 31 August 2018 * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -22,9 +22,9 @@ #include -#include "gul17/string_util.h" +#include "gul20/string_util.h" -namespace gul17 { +namespace GULNS { const std::string_view default_whitespace_characters{ " \t\r\n\a\b\f\v" }; const std::array hex_digits{ @@ -91,6 +91,6 @@ std::string_view safe_string_view(const char* char_ptr, std::size_t length) return std::string_view(char_ptr, end_ptr - char_ptr); } -} // namespace gul17 +} // namespace GULNS /* vim:set expandtab softtabstop=4 tabstop=4 shiftwidth=4 textwidth=90 cindent: */ diff --git a/src/to_number.cc b/src/to_number.cc index 7e5d205..c2b5ab0 100644 --- a/src/to_number.cc +++ b/src/to_number.cc @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 19 Februar 2024 * - * \copyright Copyright 2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2024-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -22,9 +22,9 @@ #include -#include "gul17/to_number.h" +#include "gul20/to_number.h" -namespace gul17 { +namespace GULNS { namespace detail { @@ -95,4 +95,4 @@ long double pow10(int exponent) } // namespace detail -} // namespace gul17 +} // namespace GULNS diff --git a/src/trim.cc b/src/trim.cc index 00a083f..44c1077 100644 --- a/src/trim.cc +++ b/src/trim.cc @@ -5,7 +5,7 @@ * \brief Implementation of trim(), trim_left(), trim_right(), trim_sv(), trim_left_sv(), * and trim_right_sv(). * - * \copyright Copyright 2018 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -21,9 +21,9 @@ * along with this program. If not, see . */ -#include "gul17/trim.h" +#include "gul20/trim.h" -namespace gul17 { +namespace GULNS { std::string trim(std::string_view str, std::string_view ws_chars) @@ -74,4 +74,4 @@ std::string_view trim_right_sv(std::string_view str, std::string_view ws_chars) } -} // namespace gul17 +} // namespace GULNS diff --git a/src/version.cc.in b/src/version.cc.in index af05810..4e12ba4 100644 --- a/src/version.cc.in +++ b/src/version.cc.in @@ -4,7 +4,7 @@ * \authors \ref contributors * \date Created on 14 Sep 2018 * - * \copyright Copyright 2018-2024 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,9 +20,9 @@ * along with this program. If not, see . */ -#include "gul17/version.h" +#include "gul20/version.h" // The "@ string @" sequences are replaced with the actual strings by the meson build // system and written into the build directory as version.cc. That file is compiled and // linked if specified. -char const* gul17::version{ "@FULL_VERSION@" }; +char const* GULNS::version{ "@FULL_VERSION@" }; diff --git a/tests/lint b/tests/lint index 608c32d..cb798ef 100755 --- a/tests/lint +++ b/tests/lint @@ -1,7 +1,7 @@ #!/bin/sh # # This calls our linter with useful options -# +# # Because the filter is only working in 'positive' mode, but string_view.h has so # many warnings that it shall be ignored, this is a bit complicated. @@ -19,4 +19,4 @@ clang-tidy \ -config="{Checks: 'bugprone*,cppcore*,readability*,performance*,modernize*,misc*,clang-analyzer*,-clang-analyzer-alpha.core.CastToStruct,-readability-else-after-return', \ CheckOptions: [{ key: readability-braces-around-statements.ShortStatementLines, value: '3' }]}" \ '-header-filter=.*' -line-filter=[${HEADERLIST}] $@ \ - -- -I../include -I../include/gul17 -std=c++17 + -- -I../include -I../include/gul20 -std=c++20 diff --git a/tests/test_OverloadSet.cc b/tests/test_OverloadSet.cc index 9468954..589e0eb 100644 --- a/tests/test_OverloadSet.cc +++ b/tests/test_OverloadSet.cc @@ -4,7 +4,7 @@ * \date Created on May 31, 2023 * \brief Unit tests for the OverloadSet class template. * - * \copyright Copyright 2023-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2023-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -25,13 +25,13 @@ #include -#include "gul17/OverloadSet.h" +#include "gul20/OverloadSet.h" TEST_CASE("OverloadSet: Constructor", "[variant]") { auto v = std::variant{ }; - auto get_type_name = gul17::OverloadSet{ + auto get_type_name = GULNS::OverloadSet{ [](auto&&) -> std::string { return "SOMETHING ELSE"; }, [](float) -> std::string { return "float"; }, [](double) -> std::string { return "double"; }, diff --git a/tests/test_SlidingBuffer.cc b/tests/test_SlidingBuffer.cc index d14dc7a..8f1b03d 100644 --- a/tests/test_SlidingBuffer.cc +++ b/tests/test_SlidingBuffer.cc @@ -4,7 +4,7 @@ * \date Created on Feb 7, 2019 * \brief Test suite for the SlidingBuffer{} * - * \copyright Copyright 2019-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -27,17 +27,17 @@ #include #include -#include "gul17/cat.h" -#include "gul17/join_split.h" -#include "gul17/SlidingBuffer.h" -#include "gul17/trim.h" -#include "gul17/tokenize.h" +#include "gul20/cat.h" +#include "gul20/join_split.h" +#include "gul20/SlidingBuffer.h" +#include "gul20/trim.h" +#include "gul20/tokenize.h" using namespace std::literals::string_literals; using Catch::Matchers::Matches; using Catch::Matchers::StartsWith; -using gul17::SlidingBuffer; -using gul17::SlidingBufferExposed; +using GULNS::SlidingBuffer; +using GULNS::SlidingBufferExposed; // A dummy struct for tests with nontrivial elements. struct MyStruct { @@ -192,7 +192,7 @@ void do_dumping_tests(T& buff) std::stringstream s2{ }; s2 << buff; - REQUIRE_THAT(gul17::trim(s2.str()), Matches( + REQUIRE_THAT(GULNS::trim(s2.str()), Matches( "141.4 131.3 121.2 111.1 101 90.9 80.8 70.7 60.6 50.5")); } @@ -329,7 +329,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 5); std::stringstream s{ }; s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); auto buffa = buff; @@ -339,7 +339,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 5); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); buff.resize(8); @@ -348,7 +348,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 8); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); buff.resize(11); @@ -357,7 +357,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 11); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); REQUIRE(*buff.begin() == 10); @@ -367,7 +367,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 6); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); buff.resize(5); @@ -376,7 +376,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 5); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); buffa.resize(4); @@ -385,7 +385,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buffa.capacity() == 4); s.str(""); s << buffa; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7")); buff.resize(3); @@ -394,7 +394,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 3); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8")); buff.resize(0); @@ -432,7 +432,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.back() == 3); std::stringstream s{ }; s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); auto buffa = buff; @@ -443,7 +443,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 12); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff.resize(12); @@ -452,7 +452,7 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 12); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff.resize(15); @@ -461,92 +461,92 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 15); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(14); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(13); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(12); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(11); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(10); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(9); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(8); // no change s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(7); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4")); buff = buffa; buff.resize(6); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5")); buff = buffa; buff.resize(5); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); buff = buffa; buff.resize(4); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7")); buff = buffa; buff.resize(3); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8")); buff = buffa; buff.resize(2); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9")); buff = buffa; buff.resize(1); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10")); } SECTION("filling pattern 3") { @@ -578,28 +578,28 @@ TEST_CASE("SlidingBuffer resize", "[SlidingBuffer]") REQUIRE(buff.capacity() == 8); std::stringstream s{ }; s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); auto buffa = buff; buff.resize(12); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6 5 4 3")); buff = buffa; buff.resize(5); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7 6")); buff = buffa; buff.resize(4); s.str(""); s << buff; - REQUIRE_THAT(gul17::trim(s.str()), Catch::Matchers::Matches( + REQUIRE_THAT(GULNS::trim(s.str()), Catch::Matchers::Matches( "10 9 8 7")); } } @@ -1082,7 +1082,7 @@ TEST_CASE("SlidingBuffer: mixed directions", "[SlidingBuffer]") std::stringstream s{ }; s.str(""); s << buf; - REQUIRE(gul17::trim(s.str()) == "1 2"); + REQUIRE(GULNS::trim(s.str()) == "1 2"); } SECTION("SlidingBufferExposed") { @@ -1108,7 +1108,7 @@ TEST_CASE("SlidingBuffer: resizing and begin()/end() guarantee", "[SlidingBuffer buf.push_front(1); buf.push_front(2); REQUIRE(std::distance(buf.begin(), buf.end()) == 2); - buf.resize(6, gul17::ShrinkBehavior::keep_front_elements); + buf.resize(6, GULNS::ShrinkBehavior::keep_front_elements); buf.push_front(10); buf.push_front(11); REQUIRE(std::distance(buf.begin(), buf.end()) == 4); @@ -1121,7 +1121,7 @@ TEST_CASE("SlidingBuffer: resizing and begin()/end() guarantee", "[SlidingBuffer buf.push_front(1); buf.push_front(2); REQUIRE(std::distance(buf.begin(), buf.end()) == 2); - buf.resize(10, gul17::ShrinkBehavior::keep_front_elements); + buf.resize(10, GULNS::ShrinkBehavior::keep_front_elements); buf.push_front(10); buf.push_front(11); REQUIRE(std::distance(buf.begin(), buf.end()) == 4); @@ -1134,7 +1134,7 @@ TEST_CASE("SlidingBuffer: resizing and begin()/end() guarantee", "[SlidingBuffer buf.push_back(1); buf.push_back(2); REQUIRE(std::distance(buf.begin(), buf.end()) == 2); - buf.resize(6, gul17::ShrinkBehavior::keep_back_elements); + buf.resize(6, GULNS::ShrinkBehavior::keep_back_elements); buf.push_back(10); buf.push_back(11); REQUIRE(std::distance(buf.begin(), buf.end()) == 4); @@ -1147,7 +1147,7 @@ TEST_CASE("SlidingBuffer: resizing and begin()/end() guarantee", "[SlidingBuffer buf.push_back(1); buf.push_back(2); REQUIRE(std::distance(buf.begin(), buf.end()) == 2); - buf.resize(10, gul17::ShrinkBehavior::keep_back_elements); + buf.resize(10, GULNS::ShrinkBehavior::keep_back_elements); buf.push_back(10); buf.push_back(11); REQUIRE(std::distance(buf.begin(), buf.end()) == 4); @@ -1158,10 +1158,10 @@ TEST_CASE("SlidingBuffer: resizing and begin()/end() guarantee", "[SlidingBuffer template auto do_a_dump(Buffer buf, int start, int end, bool backwards, - std::size_t resize_to, gul17::ShrinkBehavior sb, std::string head, bool print) { + std::size_t resize_to, GULNS::ShrinkBehavior sb, std::string head, bool print) { auto const omit_until = end - start >= 10 ? end - 4 : 0; head += " - push_"s + (backwards ? "back"s : "front"s); - head += " - shrink_keep_"s + (sb == gul17::ShrinkBehavior::keep_back_elements ? "back"s : "front"s); + head += " - shrink_keep_"s + (sb == GULNS::ShrinkBehavior::keep_back_elements ? "back"s : "front"s); if (print) { if (omit_until > 0) std::cout << head << "\n[...]\n"; @@ -1183,7 +1183,7 @@ auto do_a_dump(Buffer buf, int start, int end, bool backwards, std::stringstream s{ }; for (auto it = buf.begin(); it != buf.end(); ++it) s << *it << ' '; - return gul17::join(gul17::tokenize(s.str()), " "); + return GULNS::join(GULNS::tokenize(s.str()), " "); } TEST_CASE("SlidingBuffer: Shrinking behavior", "[SlidingBuffer]") @@ -1193,8 +1193,8 @@ TEST_CASE("SlidingBuffer: Shrinking behavior", "[SlidingBuffer]") auto const pf = false; // push_front auto const pb = true; // push_back - auto const sf = gul17::ShrinkBehavior::keep_front_elements; - auto const sb = gul17::ShrinkBehavior::keep_back_elements; + auto const sf = GULNS::ShrinkBehavior::keep_front_elements; + auto const sb = GULNS::ShrinkBehavior::keep_back_elements; auto const normal = "Normal"; SECTION("Buffer not yet filled, shrink with element loss") { @@ -1270,8 +1270,8 @@ TEST_CASE("SlidingBufferExposed: Shrinking behavior", "[SlidingBuffer]") auto const pf = false; // push_front auto const pb = true; // push_back - auto const sf = gul17::ShrinkBehavior::keep_front_elements; - auto const sb = gul17::ShrinkBehavior::keep_back_elements; + auto const sf = GULNS::ShrinkBehavior::keep_front_elements; + auto const sb = GULNS::ShrinkBehavior::keep_back_elements; auto const normal = "Exposed"; SECTION("Buffer not yet filled, shrink with element loss") { diff --git a/tests/test_SmallVector.cc b/tests/test_SmallVector.cc index eddf602..f276ccc 100644 --- a/tests/test_SmallVector.cc +++ b/tests/test_SmallVector.cc @@ -4,7 +4,7 @@ * \date Created on August 17, 2020 * \brief Test suite for the SmallVector class. * - * \copyright Copyright 2020-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2020-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -32,10 +32,10 @@ #include #include -#include "gul17/SmallVector.h" +#include "gul20/SmallVector.h" using namespace std::literals::string_literals; -using gul17::SmallVector; +using GULNS::SmallVector; namespace { diff --git a/tests/test_ThreadPool.cc b/tests/test_ThreadPool.cc index a20feda..a1160b4 100644 --- a/tests/test_ThreadPool.cc +++ b/tests/test_ThreadPool.cc @@ -4,7 +4,7 @@ * \date Created on March 17, 2023 * \brief Declaration of the ThreadPool class. * - * \copyright Copyright 2023-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2023-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -29,11 +29,11 @@ #include -#include "gul17/ThreadPool.h" -#include "gul17/time_util.h" -#include "gul17/Trigger.h" +#include "gul20/ThreadPool.h" +#include "gul20/time_util.h" +#include "gul20/Trigger.h" -using namespace gul17; +using namespace GULNS; using namespace std::literals; // @@ -55,12 +55,12 @@ TEST_CASE("TaskHandle: cancel()", "[ThreadPool]") std::atomic stop{ false }; - auto task1 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task2 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task3 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); + auto task1 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task2 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task3 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); while (task1.get_state() == TaskState::pending) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(task1.get_state() == TaskState::running); REQUIRE(task2.get_state() == TaskState::pending); @@ -97,9 +97,9 @@ TEST_CASE("TaskHandle: is_complete()", "[ThreadPool][TaskHandle]") std::atomic stop{ false }; - auto task1 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task2 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task3 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); + auto task1 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task2 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task3 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); REQUIRE(task1.is_complete() == false); REQUIRE(task2.is_complete() == false); @@ -117,16 +117,16 @@ TEST_CASE("TaskHandle: get_state()", "[ThreadPool][TaskHandle]") std::atomic stop{ false }; - auto task1 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task2 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task3 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); + auto task1 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task2 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task3 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); - auto t0 = gul17::tic(); + auto t0 = GULNS::tic(); while (task1.get_state() != TaskState::running) { - if (gul17::toc(t0) > 1.0) + if (GULNS::toc(t0) > 1.0) FAIL("Timeout waiting for work item to start"); - gul17::sleep(1ms); + GULNS::sleep(1ms); } // id1 might have been assigned to the work thread already, but in any case the other @@ -139,12 +139,12 @@ TEST_CASE("TaskHandle: get_state()", "[ThreadPool][TaskHandle]") stop = true; - t0 = gul17::tic(); + t0 = GULNS::tic(); while (task1.get_state() == TaskState::running) { - if (gul17::toc(t0) > 1.0) + if (GULNS::toc(t0) > 1.0) FAIL("Timeout waiting for work item to stop"); - gul17::sleep(1ms); + GULNS::sleep(1ms); } REQUIRE(task1.get_state() == TaskState::complete); @@ -189,7 +189,7 @@ TEST_CASE("ThreadPool: add_task() for functions without ThreadPool&", "[ThreadPo std::atomic done{ false }; pool->add_task( - [&start]() { while (!start) gul17::sleep(10us); }); + [&start]() { while (!start) GULNS::sleep(10us); }); auto handle = pool->add_task( [&done]() { done = true; }, "Task 2"); @@ -200,7 +200,7 @@ TEST_CASE("ThreadPool: add_task() for functions without ThreadPool&", "[ThreadPo start = true; while (not pool->is_idle()) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(done); @@ -221,12 +221,12 @@ TEST_CASE("ThreadPool: add_task() for functions without ThreadPool&", "[ThreadPo "task 3 (usually runs first)"); while (last_job == 0) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(last_job >= 2); REQUIRE(last_job <= 3); while (pool->count_pending() > 1) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(task1.get_state() == TaskState::pending); task1.cancel(); @@ -243,12 +243,12 @@ TEST_CASE("ThreadPool: add_task() for functions without ThreadPool&", "[ThreadPo "task 3 (usually runs first)"); while (last_job == 0) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(last_job >= 2); REQUIRE(last_job <= 3); while (pool->count_pending() > 1) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(task1.get_state() == TaskState::pending); task1.cancel(); @@ -267,7 +267,7 @@ TEST_CASE("ThreadPool: add_task(f(ThreadPool&, ...))", "[ThreadPool]") std::atomic done{ false }; pool->add_task( - [&start](ThreadPool&) { while (!start) gul17::sleep(10us); }); + [&start](ThreadPool&) { while (!start) GULNS::sleep(10us); }); auto handle = pool->add_task( [&done](ThreadPool&) { done = true; }, "Task 2"); @@ -278,7 +278,7 @@ TEST_CASE("ThreadPool: add_task(f(ThreadPool&, ...))", "[ThreadPool]") start = true; while (not pool->is_idle()) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(done); @@ -299,12 +299,12 @@ TEST_CASE("ThreadPool: add_task(f(ThreadPool&, ...))", "[ThreadPool]") "task 3 (usually runs first)"); while (last_job == 0) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(last_job >= 2); REQUIRE(last_job <= 3); while (pool->count_pending() > 1) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(task1.get_state() == TaskState::pending); task1.cancel(); @@ -322,12 +322,12 @@ TEST_CASE("ThreadPool: add_task(f(ThreadPool&, ...))", "[ThreadPool]") "task 3 (usually runs first)"); while (last_job == 0) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(last_job >= 2); REQUIRE(last_job <= 3); while (pool->count_pending() > 1) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(task1.get_state() == TaskState::pending); task1.cancel(); @@ -343,12 +343,12 @@ TEST_CASE("ThreadPool: cancel_pending_tasks()", "[ThreadPool]") std::atomic stop{ false }; - auto task1 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task2 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); - auto task3 = pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); + auto task1 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task2 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); + auto task3 = pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); while (task1.get_state() == TaskState::pending) - gul17::sleep(1ms); + GULNS::sleep(1ms); REQUIRE(task1.get_state() != TaskState::complete); REQUIRE(task1.get_state() != TaskState::canceled); @@ -381,7 +381,7 @@ TEST_CASE("ThreadPool: count_pending()", "[ThreadPool]") for (std::size_t i = 0; i <= 10; ++i) { REQUIRE(pool->is_full() == false); - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); } // One work item might already be executing, the queue should have 10 or 11 pending @@ -412,12 +412,12 @@ TEST_CASE("ThreadPool: get_pending_task_names()", "[ThreadPool]") std::atomic stop{ false }; - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }, "1"); - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }, "2"); - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }, "3"); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }, "1"); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }, "2"); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }, "3"); while (pool->count_pending() == 3) - gul17::sleep(1ms); + GULNS::sleep(1ms); auto pending_names = pool->get_pending_task_names(); REQUIRE(pending_names.size() == 2); @@ -438,11 +438,11 @@ TEST_CASE("ThreadPool: get_running_task_names()", "[ThreadPool]") std::atomic stop{ false }; - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }, "1"); - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }, "2"); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }, "1"); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }, "2"); while (pool->count_pending() == 2) - gul17::sleep(1ms); + GULNS::sleep(1ms); auto running_names = pool->get_running_task_names(); REQUIRE(running_names.size() == 1); @@ -467,7 +467,7 @@ TEST_CASE("ThreadPool: get_thread_id()", "[ThreadPool]") [&](ThreadPool& p) { trigger.wait(); indices[1] = p.get_thread_id(); }); while (pool->count_pending() > 0) - gul17::sleep(1ms); + GULNS::sleep(1ms); trigger = true; @@ -491,17 +491,17 @@ TEST_CASE("ThreadPool: is_full()", "[ThreadPool]") std::atomic stop{ false }; - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); // Wait until the first task is running while (pool->count_pending() > 0) - gul17::sleep(1ms); + GULNS::sleep(1ms); // Enqueue tasks up to the capacity of the pool for (std::size_t i = 1; i <= pool->capacity(); ++i) { REQUIRE(pool->is_full() == false); - pool->add_task([&stop]() { while (!stop) gul17::sleep(10us); }); + pool->add_task([&stop]() { while (!stop) GULNS::sleep(10us); }); } // One work item is currently executing, the queue is full @@ -545,7 +545,7 @@ TEST_CASE("ThreadPool: Run 100 functions on a single thread, check order", "[Thr { REQUIRE(pool->count_pending() <= functions.size()); REQUIRE(pool->count_pending() <= pool->capacity()); - gul17::sleep(1ms); + GULNS::sleep(1ms); } REQUIRE(output.size() == 100); @@ -573,7 +573,7 @@ TEST_CASE("ThreadPool: Run 100 functions on 4 threads", "[ThreadPool]") std::lock_guard lock(mutex); output.push_back(i); } - gul17::sleep(100us); + GULNS::sleep(100us); }); } @@ -581,7 +581,7 @@ TEST_CASE("ThreadPool: Run 100 functions on 4 threads", "[ThreadPool]") { REQUIRE(pool->count_pending() <= 100); REQUIRE(pool->count_pending() <= pool->capacity()); - gul17::sleep(1ms); + GULNS::sleep(1ms); } REQUIRE(output.size() == 100); @@ -608,20 +608,20 @@ TEST_CASE("ThreadPool: Capacity limit", "[ThreadPool]") [&go]() { while (!go) - gul17::sleep(100us); + GULNS::sleep(100us); }); } // Wait until first job has started while (pool->count_pending() != max_jobs - 1) - gul17::sleep(1ms); + GULNS::sleep(1ms); // Add yet another task, filling the queue pool->add_task( [&go]() { while (!go) - gul17::sleep(100us); + GULNS::sleep(100us); }); REQUIRE(pool->is_full()); @@ -632,7 +632,7 @@ TEST_CASE("ThreadPool: Capacity limit", "[ThreadPool]") while (not pool->is_idle()) { REQUIRE(pool->count_pending() <= max_jobs); - gul17::sleep(1ms); + GULNS::sleep(1ms); } REQUIRE_NOTHROW(pool->add_task([]() {})); @@ -676,7 +676,7 @@ TEST_CASE("ThreadPool: Tasks scheduling their own continuation", "[ThreadPool]") }); while (not pool->is_idle()) - gul17::sleep(1ms); + GULNS::sleep(1ms); { std::lock_guard lock(mutex); diff --git a/tests/test_Trigger.cc b/tests/test_Trigger.cc index fab1fd4..d24dcbd 100644 --- a/tests/test_Trigger.cc +++ b/tests/test_Trigger.cc @@ -4,7 +4,7 @@ * \date Created on September 21, 2018 * \brief Test suite for the Trigger class from the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -24,15 +24,15 @@ #include -#include "gul17/time_util.h" -#include "gul17/Trigger.h" +#include "gul20/time_util.h" +#include "gul20/Trigger.h" using namespace std::literals; -using gul17::tic; -using gul17::toc; -using gul17::sleep; -using gul17::Trigger; +using GULNS::tic; +using GULNS::toc; +using GULNS::sleep; +using GULNS::Trigger; TEST_CASE("Construction, assignment, equality and bool operator work", "[Trigger]") { diff --git a/tests/test_backports.cc b/tests/test_backports.cc index 06d178e..a0cda7b 100644 --- a/tests/test_backports.cc +++ b/tests/test_backports.cc @@ -4,7 +4,7 @@ * \date Created on August 30, 2018 * \brief Test suite for standard library backports in the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -20,32 +20,15 @@ * along with this program. If not, see . */ -#include #include -#include "gul17/date.h" -#include "gul17/span.h" +#include "gul20/date.h" using namespace std::literals; -TEMPLATE_TEST_CASE("span", "[span]", signed char, unsigned char, short, unsigned short, - int, unsigned int, long, unsigned long, long long, unsigned long long) -{ - TestType arr[5] { 1, 2, 3, 4, 5 }; - - gul17::span s; - REQUIRE(s.empty()); - - s = arr; - REQUIRE(s.size() == 5u); - - for (auto i = 0u; i < s.size(); i++) - REQUIRE(arr[i] == s[i]); -} - TEST_CASE("date", "[date]") { - using namespace gul17::date; + using namespace GULNS::date; constexpr year_month_day ymd = 2015_y/March/22; diff --git a/tests/test_bit_manip.cc b/tests/test_bit_manip.cc index dff746e..f3d8439 100644 --- a/tests/test_bit_manip.cc +++ b/tests/test_bit_manip.cc @@ -4,7 +4,7 @@ * \date Created on 17 Oct 2019 * \brief Unit tests for bit_set(), bit_reset(), bit_flip(), bit_test(). * - * \copyright Copyright 2019-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -25,39 +25,39 @@ #include #include -#include "gul17/bit_manip.h" +#include "gul20/bit_manip.h" TEMPLATE_TEST_CASE("All bit_*() functions", "[bit_manip]", char, unsigned char, signed char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long) { - auto x = gul17::bit_set(2); // 0x04 + auto x = GULNS::bit_set(2); // 0x04 REQUIRE(x == 0x04); REQUIRE(std::is_same::value == true); - auto y = gul17::bit_set(x, 4); // 0x10 + auto y = GULNS::bit_set(x, 4); // 0x10 REQUIRE(y == 0x14); REQUIRE(std::is_same::value == true); - auto z = gul17::bit_flip(y, 0); // 0x01 + auto z = GULNS::bit_flip(y, 0); // 0x01 REQUIRE(z == 0x15); REQUIRE(std::is_same::value == true); - z = gul17::bit_flip(z, 2); // 0x04 + z = GULNS::bit_flip(z, 2); // 0x04 REQUIRE(z == 0x11); - auto a = gul17::bit_reset(z, 4); // 0x10 + auto a = GULNS::bit_reset(z, 4); // 0x10 REQUIRE(a == 0x01); REQUIRE(std::is_same::value == true); - a = gul17::bit_reset(a, 3); // 0x08 + a = GULNS::bit_reset(a, 3); // 0x08 REQUIRE(a == 0x01); - auto b = gul17::bit_test(a, 0); // 0x01 + auto b = GULNS::bit_test(a, 0); // 0x01 REQUIRE(b == true); REQUIRE(std::is_same::value == true); - b = gul17::bit_test(a, 1); // 0x02 + b = GULNS::bit_test(a, 1); // 0x02 REQUIRE(b == false); } @@ -67,32 +67,32 @@ TEMPLATE_TEST_CASE("Access MSB", "[bit_manip]", { auto const msb = sizeof(TestType) * 8 - 1; - auto x = gul17::bit_set(msb); + auto x = GULNS::bit_set(msb); if (std::is_signed::value) REQUIRE(x < 0); else REQUIRE(x > 0); - REQUIRE(gul17::bit_test(x, msb) == true); - REQUIRE(gul17::bit_test(x, msb - 1) == false); + REQUIRE(GULNS::bit_test(x, msb) == true); + REQUIRE(GULNS::bit_test(x, msb - 1) == false); } TEST_CASE("is_little_endian(), is_big_endian()", "[bit_manip]") { - REQUIRE(gul17::is_little_endian() != gul17::is_big_endian()); + REQUIRE(GULNS::is_little_endian() != GULNS::is_big_endian()); const std::uint32_t val = 0x01'02'03'04; const char* chars = reinterpret_cast(&val); - if (gul17::is_little_endian()) + if (GULNS::is_little_endian()) { REQUIRE(chars[0] == 4); REQUIRE(chars[1] == 3); REQUIRE(chars[2] == 2); REQUIRE(chars[3] == 1); } - else if (gul17::is_big_endian()) + else if (GULNS::is_big_endian()) { REQUIRE(chars[0] == 1); REQUIRE(chars[1] == 2); diff --git a/tests/test_case_ascii.cc b/tests/test_case_ascii.cc index 2f3cbe9..3560b4e 100644 --- a/tests/test_case_ascii.cc +++ b/tests/test_case_ascii.cc @@ -5,7 +5,7 @@ * \brief Test suite for lowercase_ascii(), lowercase_ascii_inplace(), uppercase_ascii(), * and uppercase_ascii_inplace(). * - * \copyright Copyright 2019-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -23,10 +23,10 @@ #include -#include "gul17/case_ascii.h" +#include "gul20/case_ascii.h" using namespace std::literals; -using namespace gul17; +using namespace GULNS; TEST_CASE("lowercase_ascii()", "[case_ascii]") { diff --git a/tests/test_cat.cc b/tests/test_cat.cc index b0a9010..351a357 100644 --- a/tests/test_cat.cc +++ b/tests/test_cat.cc @@ -4,7 +4,7 @@ * \date Created on August 30, 2018 * \brief Test suite for cat() from the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -22,12 +22,12 @@ #include - #include "gul17/cat.h" + #include "gul20/cat.h" using namespace std::literals; -using gul17::cat; +using GULNS::cat; -TEST_CASE("gul17::cat() works for fixed test cases from 0 to 6 arguments", "[cat]") +TEST_CASE("GULNS::cat() works for fixed test cases from 0 to 6 arguments", "[cat]") { REQUIRE(cat() == ""); REQUIRE(cat("Lo") == "Lo"); diff --git a/tests/test_escape.cc b/tests/test_escape.cc index cbd1f90..d1746cf 100644 --- a/tests/test_escape.cc +++ b/tests/test_escape.cc @@ -4,7 +4,7 @@ * \date Created on August 31, 2018 * \brief Part of test suite for string utility functions in the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -24,37 +24,37 @@ #include -#include "gul17/cat.h" -#include "gul17/escape.h" +#include "gul20/cat.h" +#include "gul20/escape.h" using namespace std::literals; TEST_CASE("Compare escaped strings", "[escape]") { - REQUIRE(gul17::escape("foo bar baz"s) == "foo bar baz"s); + REQUIRE(GULNS::escape("foo bar baz"s) == "foo bar baz"s); // This shows the design idea quite nice: - REQUIRE(gul17::escape("foo\rbar\nfoobar\tbaz\\qux\""s) == + REQUIRE(GULNS::escape("foo\rbar\nfoobar\tbaz\\qux\""s) == R"(foo\rbar\nfoobar\tbaz\\qux\")"s); - REQUIRE(gul17::escape("foo\abar\000baz"s) == R"(foo\x07bar\x00baz)"s); + REQUIRE(GULNS::escape("foo\abar\000baz"s) == R"(foo\x07bar\x00baz)"s); - REQUIRE(gul17::escape("\xff") == "\\xff"); + REQUIRE(GULNS::escape("\xff") == "\\xff"); } TEST_CASE("Compare unescaped strings", "[escape]") { - REQUIRE(gul17::unescape("foo bar baz"s) == "foo bar baz"s); + REQUIRE(GULNS::unescape("foo bar baz"s) == "foo bar baz"s); - REQUIRE(gul17::unescape(R"(foo\rbar\nfoobar\tbaz\\qux\")"s) == + REQUIRE(GULNS::unescape(R"(foo\rbar\nfoobar\tbaz\\qux\")"s) == "foo\rbar\nfoobar\tbaz\\qux\""s); - REQUIRE(gul17::unescape(R"(foo\x07bar\x00baz)"s) == "foo\abar\000baz"s); + REQUIRE(GULNS::unescape(R"(foo\x07bar\x00baz)"s) == "foo\abar\000baz"s); - REQUIRE(gul17::unescape("\\xff") == "\xff"); + REQUIRE(GULNS::unescape("\\xff") == "\xff"); auto const s = "foo\abar\000baz"s; - REQUIRE(gul17::unescape(gul17::escape(s)) == s); + REQUIRE(GULNS::unescape(GULNS::escape(s)) == s); } TEST_CASE("Check escaping and unescaping with random strings", "[escape]") @@ -70,26 +70,26 @@ TEST_CASE("Check escaping and unescaping with random strings", "[escape]") for (char &c : original) c = static_cast(uniform_dist(re)); - auto escaped = gul17::escape(original); + auto escaped = GULNS::escape(original); REQUIRE(original.length() <= escaped.length()); - auto unescaped = gul17::unescape(escaped); + auto unescaped = GULNS::unescape(escaped); if (original != unescaped) { - INFO(gul17::cat("Original \"", original, "\" != \"", unescaped, + INFO(GULNS::cat("Original \"", original, "\" != \"", unescaped, "\" after escape/unescape")); std::string str = "Original bytes: "; for (const char &c : original) - str += gul17::cat("[", static_cast(c), "] "); + str += GULNS::cat("[", static_cast(c), "] "); str += "\nBytes after escape/unescape: "; for (const char &c : unescaped) - str += gul17::cat("[", static_cast(c), "] "); + str += GULNS::cat("[", static_cast(c), "] "); FAIL(str); } diff --git a/tests/test_expected.cc b/tests/test_expected.cc index 80c9a76..c9f6ae2 100644 --- a/tests/test_expected.cc +++ b/tests/test_expected.cc @@ -4,7 +4,7 @@ * \date Created on March 20, 2023 * \brief Unit tests for the expected class template. * - * \copyright Copyright 2023-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2023-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -27,7 +27,7 @@ #include #include -#include "gul17/expected.h" +#include "gul20/expected.h" using namespace std::literals; @@ -37,10 +37,10 @@ using namespace std::literals; namespace { -gul17::expected unexpected_if_negative(int value) +GULNS::expected unexpected_if_negative(int value) { if (value < 0) - return gul17::unexpected("error"); + return GULNS::unexpected("error"); return value; } @@ -50,7 +50,7 @@ gul17::expected unexpected_if_negative(int value) TEMPLATE_TEST_CASE("expected: Default constructor", "[expected]", int, std::string, std::unique_ptr) { - gul17::expected ex; + GULNS::expected ex; REQUIRE(ex.value() == TestType{}); } @@ -65,12 +65,12 @@ TEST_CASE("expected: and_then()", "[expected]") TEST_CASE("expected: has_value()", "[expected]") { - gul17::expected ex; + GULNS::expected ex; REQUIRE(ex.has_value() == true); REQUIRE(*ex == 0); - ex = gul17::unexpected("error"); + ex = GULNS::unexpected("error"); REQUIRE(ex.has_value() == false); REQUIRE(ex.error() == "error"); @@ -81,11 +81,11 @@ TEST_CASE("expected: has_value()", "[expected]") TEST_CASE("value()", "[expected]") { - gul17::expected ex{ 42 }; + GULNS::expected ex{ 42 }; REQUIRE(ex.value() == 42); - ex = gul17::unexpected("error"); - REQUIRE_THROWS_AS(ex.value(), gul17::bad_expected_access); // base class - REQUIRE_THROWS_AS(ex.value(), gul17::bad_expected_access); // derived class + ex = GULNS::unexpected("error"); + REQUIRE_THROWS_AS(ex.value(), GULNS::bad_expected_access); // base class + REQUIRE_THROWS_AS(ex.value(), GULNS::bad_expected_access); // derived class } diff --git a/tests/test_finalizer.cc b/tests/test_finalizer.cc index 2cb3992..927da88 100644 --- a/tests/test_finalizer.cc +++ b/tests/test_finalizer.cc @@ -3,7 +3,7 @@ * \author \ref contributors * \brief Test suite for hexdump() and hexdump_stream(). * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -25,14 +25,14 @@ #include -#include "gul17/finalizer.h" +#include "gul20/finalizer.h" TEST_CASE("Finalizer Tests", "[finalizer]") { SECTION("Closure as temporary") { int foo = 1; { - auto _ = gul17::finally([&foo] { foo += 2; }); + auto _ = GULNS::finally([&foo] { foo += 2; }); } REQUIRE(foo == 3); } @@ -44,7 +44,7 @@ TEST_CASE("Finalizer Tests", "[finalizer]") auto xxx = [&foo] { foo += 2; }; auto yyy { xxx }; - auto _ = gul17::finally(yyy); + auto _ = GULNS::finally(yyy); } REQUIRE(foo == 3); } @@ -60,7 +60,7 @@ TEST_CASE("Finalizer Tests", "[finalizer]") foo = 1; { auto yyy{ xxx }; - auto _ = gul17::finally(yyy); + auto _ = GULNS::finally(yyy); } REQUIRE(foo == 3); REQUIRE(xxx() == 2); @@ -75,7 +75,7 @@ TEST_CASE("Finalizer Tests", "[finalizer]") auto xxx = [&foo] { foo += 2; }; auto yyy { xxx }; - auto _ = gul17::FinalAction(yyy); + auto _ = GULNS::FinalAction(yyy); } REQUIRE(foo == 3); } @@ -83,7 +83,7 @@ TEST_CASE("Finalizer Tests", "[finalizer]") SECTION("Call on exception") { int foo = 1; try { - auto _ = gul17::finally([&foo] { foo += 2; }); + auto _ = GULNS::finally([&foo] { foo += 2; }); throw "Foo bar"; } catch (...) { foo++; @@ -99,7 +99,7 @@ TEST_CASE("Finalizer Tests", "[finalizer]") buffer = new char[100]; if (buffer == nullptr) break; - auto _ = gul17::finally([&buffer] { delete[] buffer; buffer = nullptr; }); + auto _ = GULNS::finally([&buffer] { delete[] buffer; buffer = nullptr; }); snprintf(buffer, 100, "%.1f", some_float); some_string = buffer; @@ -115,7 +115,7 @@ TEST_CASE("Finalizer Tests", "[finalizer]") SECTION("Closure move") { int foo = 1; { - auto _1 = gul17::finally([&foo]() { foo += 2; }); + auto _1 = GULNS::finally([&foo]() { foo += 2; }); { auto _2 = std::move(_1); REQUIRE(foo == 1); @@ -147,7 +147,7 @@ TEST_CASE("Finalizer with function", "[finalizer]") SECTION("Function pointer temporary") { global_foo = 1; { - auto _ = gul17::finally(&helper); + auto _ = GULNS::finally(&helper); } REQUIRE(global_foo == 3); } @@ -156,7 +156,7 @@ TEST_CASE("Finalizer with function", "[finalizer]") global_foo = 1; { auto x = &helper; - auto _ = gul17::finally(x); + auto _ = GULNS::finally(x); } REQUIRE(global_foo == 3); } @@ -165,9 +165,9 @@ TEST_CASE("Finalizer with function", "[finalizer]") global_foo = 1; { auto x = &helper; - auto a = gul17::finally(x); + auto a = GULNS::finally(x); { - auto b = gul17::finally(x); + auto b = GULNS::finally(x); b = std::move(a); REQUIRE(global_foo == 1); } @@ -180,7 +180,7 @@ TEST_CASE("Finalizer with function", "[finalizer]") global_foo = 1; { // Lazy man's version, implicit conversion to function pointer - auto _ = gul17::finally(helper); + auto _ = GULNS::finally(helper); } REQUIRE(global_foo == 3); } @@ -189,7 +189,7 @@ TEST_CASE("Finalizer with function", "[finalizer]") global_foo = 1; { // Use FinalAction directly - auto _ = gul17::FinalAction(helper); + auto _ = GULNS::FinalAction(helper); } REQUIRE(global_foo == 3); } @@ -199,7 +199,7 @@ TEST_CASE("Finalizer with function", "[finalizer]") { // Use FinalAction directly auto x = &helper; - auto _ = gul17::FinalAction(helper); + auto _ = GULNS::FinalAction(helper); } REQUIRE(global_foo == 3); } @@ -208,7 +208,7 @@ TEST_CASE("Finalizer with function", "[finalizer]") global_foo = 1; { // Use FinalAction directly - auto _ = gul17::FinalAction(helper); + auto _ = GULNS::FinalAction(helper); } REQUIRE(global_foo == 3); } @@ -216,7 +216,7 @@ TEST_CASE("Finalizer with function", "[finalizer]") SECTION("finally with std::bind") { int foo = 1; { - auto _ = gul17::finally(std::bind(&helper2, std::ref(foo))); + auto _ = GULNS::finally(std::bind(&helper2, std::ref(foo))); CHECK(foo == 1); } CHECK(foo == 3); diff --git a/tests/test_gcd_lcm.cc b/tests/test_gcd_lcm.cc index d7e5cd4..f41e961 100644 --- a/tests/test_gcd_lcm.cc +++ b/tests/test_gcd_lcm.cc @@ -4,7 +4,7 @@ * \date Created on August 5, 2022 * \brief Test suite for gcd() and lcm(). * - * \copyright Copyright 2022-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2022-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -24,10 +24,10 @@ #include -#include "gul17/gcd_lcm.h" +#include "gul20/gcd_lcm.h" -using gul17::gcd; -using gul17::lcm; +using GULNS::gcd; +using GULNS::lcm; TEST_CASE("gcd(): Explicit test cases", "[gcd_lcm]") { diff --git a/tests/test_hexdump.cc b/tests/test_hexdump.cc index 864ff60..21d4798 100644 --- a/tests/test_hexdump.cc +++ b/tests/test_hexdump.cc @@ -4,7 +4,7 @@ * \date Created on September 25, 2018 * \brief Test suite for hexdump() and hexdump_stream(). * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -26,55 +26,55 @@ #include -#include "gul17/hexdump.h" +#include "gul20/hexdump.h" using namespace std::literals::string_literals; TEST_CASE("Hexdump Test", "[hexdump]") { SECTION("empty dump test") { - std::string x = gul17::hexdump(""s); + std::string x = GULNS::hexdump(""s); auto answer1 = "000000: \n"s; REQUIRE(x == answer1); auto oss1 = std::ostringstream{ }; - oss1 << gul17::hexdump_stream(""s); + oss1 << GULNS::hexdump_stream(""s); REQUIRE(oss1.str() == answer1); } SECTION("dump strings") { auto x = "test\nthe Ä west!\t\r\n"s; - auto a1 = gul17::hexdump(x.begin(), x.end(), "deBuk -> "); + auto a1 = GULNS::hexdump(x.begin(), x.end(), "deBuk -> "); auto answer1 = "deBuk -> 000000: 74 65 73 74 0a 74 68 65 20 c3 84 20 77 65 73 74 test.the .. west\n" " 000010: 21 09 0d 0a !...\n"s; REQUIRE(a1 == answer1); auto oss1 = std::ostringstream{ }; - oss1 << gul17::hexdump_stream(x.begin(), x.end(), "deBuk -> "); + oss1 << GULNS::hexdump_stream(x.begin(), x.end(), "deBuk -> "); REQUIRE(oss1.str() == answer1); - auto a2 = gul17::hexdump(x, "deBak -> "); + auto a2 = GULNS::hexdump(x, "deBak -> "); auto answer2 = "deBak -> 000000: 74 65 73 74 0a 74 68 65 20 c3 84 20 77 65 73 74 test.the .. west\n" " 000010: 21 09 0d 0a !...\n"s; REQUIRE(a2 == answer2); auto oss3 = std::ostringstream{ }; - oss3 << gul17::hexdump_stream(x, "deBak -> "); + oss3 << GULNS::hexdump_stream(x, "deBak -> "); REQUIRE(oss3.str() == answer2); } SECTION("dump full container") { auto ar = std::array{{ 0, 1, 5, 2, -0x300fffff, 2, 5, 1999 }}; - auto a1 = gul17::hexdump(ar); + auto a1 = GULNS::hexdump(ar); auto answer1 = "000000: 00000000 00000001 00000005 00000002 cff00001 00000002 00000005 000007cf \n"s; REQUIRE(a1 == answer1); auto oss1 = std::ostringstream{ }; - oss1 << gul17::hexdump_stream(ar); + oss1 << GULNS::hexdump_stream(ar); REQUIRE(oss1.str() == answer1); auto oss2 = std::ostringstream{ }; - auto hdp_forward = gul17::hexdump_stream(std::array{{ 0, 1, 5, 2, -0x300fffff, 2, 5, 1999 }}); + auto hdp_forward = GULNS::hexdump_stream(std::array{{ 0, 1, 5, 2, -0x300fffff, 2, 5, 1999 }}); { // We need this complicate construct to replace the remnants of the temporary above with some // different object on the stack. ar2 now lives in the memory space of the temporary array @@ -89,23 +89,23 @@ TEST_CASE("Hexdump Test", "[hexdump]") // Check if ar has been moved and left us with a corpse // Is ar still the same? auto oss3 = std::ostringstream{ }; - oss3 << gul17::hexdump_stream(ar); + oss3 << GULNS::hexdump_stream(ar); REQUIRE(oss3.str() == answer1); } SECTION("dump with iterators") { std::array ar = {{ 0, 1, 5, 2, -0x300fffff, 2, 5, 1999 }}; - auto a1 = gul17::hexdump(ar.begin(), ar.end()); + auto a1 = GULNS::hexdump(ar.begin(), ar.end()); auto answer1 = "000000: 00000000 00000001 00000005 00000002 cff00001 00000002 00000005 000007cf \n"s; REQUIRE(a1 == answer1); auto oss1 = std::ostringstream{ }; - oss1 << gul17::hexdump_stream(ar.begin(), ar.end()); + oss1 << GULNS::hexdump_stream(ar.begin(), ar.end()); REQUIRE(oss1.str() == answer1); } SECTION("dump unsigned long long") { std::array ar = {{ std::numeric_limits::max() }}; - auto a1 = gul17::hexdump(ar); + auto a1 = GULNS::hexdump(ar); auto answer1 = "000000: " + std::string(sizeof(ar[0]) * 2, 'f') + " \n"s; REQUIRE(a1 == answer1); } diff --git a/tests/test_join_split.cc b/tests/test_join_split.cc index f8c9aa6..20e6e49 100644 --- a/tests/test_join_split.cc +++ b/tests/test_join_split.cc @@ -4,7 +4,7 @@ * \date Created on August 31, 2018 * \brief Test suite for join(), split(), and split_sv(). * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -34,14 +34,14 @@ #include #include -#include "gul17/join_split.h" -#include "gul17/SmallVector.h" +#include "gul20/join_split.h" +#include "gul20/SmallVector.h" using namespace std::literals; -using gul17::SmallVector; -using gul17::split; -using gul17::split_sv; -using gul17::join; +using GULNS::SmallVector; +using GULNS::split; +using GULNS::split_sv; +using GULNS::join; TEST_CASE("split(std::string_view, std::string_view) with default return type", "[join_split]") { diff --git a/tests/test_main.cc b/tests/test_main.cc index f335c0c..6394600 100644 --- a/tests/test_main.cc +++ b/tests/test_main.cc @@ -4,7 +4,7 @@ * \date Created on August 28, 2018 * \brief Test suite for the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 diff --git a/tests/test_num_util.cc b/tests/test_num_util.cc index d7e52e4..e7b85d3 100644 --- a/tests/test_num_util.cc +++ b/tests/test_num_util.cc @@ -4,7 +4,7 @@ * \date Created on 7 Feb 2019 * \brief Unit tests for within_orders(), within_abs(), and within_ulp(). * - * \copyright Copyright 2019-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -25,274 +25,274 @@ #include #include -#include "gul17/num_util.h" +#include "gul20/num_util.h" using Catch::Matchers::WithinAbs; TEST_CASE("test within_orders()", "[num_util]") { - REQUIRE(gul17::within_orders(1.0, 101.0, 2) == false); - REQUIRE(gul17::within_orders(101.0, 1.0, 2) == false); - REQUIRE(gul17::within_orders(1.01l, 1.0201l, 2) == true); - REQUIRE(gul17::within_orders(1.01l, 1.0902l, 2) == false); - REQUIRE(gul17::within_orders(1.01, 1.02, 2) == true); - REQUIRE(gul17::within_orders(1.01, 1.002, 2) == true); + REQUIRE(GULNS::within_orders(1.0, 101.0, 2) == false); + REQUIRE(GULNS::within_orders(101.0, 1.0, 2) == false); + REQUIRE(GULNS::within_orders(1.01l, 1.0201l, 2) == true); + REQUIRE(GULNS::within_orders(1.01l, 1.0902l, 2) == false); + REQUIRE(GULNS::within_orders(1.01, 1.02, 2) == true); + REQUIRE(GULNS::within_orders(1.01, 1.002, 2) == true); // crossing zero - REQUIRE(gul17::within_orders(1.0, -2.0, 2) == false); - REQUIRE(gul17::within_orders(-1.01, 1.02, 2) == false); - REQUIRE(gul17::within_orders(-1.01, -1.02, 2) == true); + REQUIRE(GULNS::within_orders(1.0, -2.0, 2) == false); + REQUIRE(GULNS::within_orders(-1.01, 1.02, 2) == false); + REQUIRE(GULNS::within_orders(-1.01, -1.02, 2) == true); // negative orders - REQUIRE(gul17::within_orders(1.0, 100.0, -2) == true); + REQUIRE(GULNS::within_orders(1.0, 100.0, -2) == true); // equal digits marked: 12345 - REQUIRE(gul17::within_orders(0.6482831, 0.6482843, 2) == true); - REQUIRE(gul17::within_orders(0.6482831, 0.6482843, 3) == true); - REQUIRE(gul17::within_orders(0.6482831, 0.6482843, 4) == true); - REQUIRE(gul17::within_orders(0.6482831, 0.6482843, 5) == true); - REQUIRE(gul17::within_orders(0.6482831, 0.6482843, 6) == false); - REQUIRE(gul17::within_orders(0.6482831, 0.6482843, 7) == false); - REQUIRE(gul17::within_orders(0.6482831, 0.6482843, 8) == false); + REQUIRE(GULNS::within_orders(0.6482831, 0.6482843, 2) == true); + REQUIRE(GULNS::within_orders(0.6482831, 0.6482843, 3) == true); + REQUIRE(GULNS::within_orders(0.6482831, 0.6482843, 4) == true); + REQUIRE(GULNS::within_orders(0.6482831, 0.6482843, 5) == true); + REQUIRE(GULNS::within_orders(0.6482831, 0.6482843, 6) == false); + REQUIRE(GULNS::within_orders(0.6482831, 0.6482843, 7) == false); + REQUIRE(GULNS::within_orders(0.6482831, 0.6482843, 8) == false); // equal digits marked: 1 23456 - REQUIRE(gul17::within_orders(3.6482831, 3.6482843, 2) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482843, 3) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482843, 4) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482843, 5) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482843, 6) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482843, 7) == false); - REQUIRE(gul17::within_orders(3.6482831, 3.6482843, 8) == false); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482843, 2) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482843, 3) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482843, 4) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482843, 5) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482843, 6) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482843, 7) == false); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482843, 8) == false); // equal digits marked: 1 23456 - REQUIRE(gul17::within_orders(3.6482831, 3.6482820, 2) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482820, 3) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482820, 4) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482820, 5) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482820, 6) == true); - REQUIRE(gul17::within_orders(3.6482831, 3.6482820, 7) == false); - REQUIRE(gul17::within_orders(3.6482831, 3.6482820, 8) == false); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482820, 2) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482820, 3) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482820, 4) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482820, 5) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482820, 6) == true); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482820, 7) == false); + REQUIRE(GULNS::within_orders(3.6482831, 3.6482820, 8) == false); // equal digits marked: 1234 56 - REQUIRE(gul17::within_orders(3648.2831, 3648.2843, 2) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2843, 3) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2843, 4) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2843, 5) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2843, 6) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2843, 7) == false); - REQUIRE(gul17::within_orders(3648.2831, 3648.2843, 8) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2843, 2) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2843, 3) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2843, 4) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2843, 5) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2843, 6) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2843, 7) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2843, 8) == false); // equal digits marked: 1234 5 - REQUIRE(gul17::within_orders(3648.2831, 3648.2743, 2) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2743, 3) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2743, 4) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2743, 5) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.2743, 6) == false); - REQUIRE(gul17::within_orders(3648.2831, 3648.2743, 7) == false); - REQUIRE(gul17::within_orders(3648.2831, 3648.2743, 8) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2743, 2) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2743, 3) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2743, 4) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2743, 5) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2743, 6) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2743, 7) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.2743, 8) == false); // equal digits marked: 1234 - REQUIRE(gul17::within_orders(3648.2831, 3648.3843, 2) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.3843, 3) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.3843, 4) == true); - REQUIRE(gul17::within_orders(3648.2831, 3648.3843, 5) == false); - REQUIRE(gul17::within_orders(3648.2831, 3648.3843, 6) == false); - REQUIRE(gul17::within_orders(3648.2831, 3648.3843, 7) == false); - REQUIRE(gul17::within_orders(3648.2831, 3648.3843, 8) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.3843, 2) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.3843, 3) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.3843, 4) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3648.3843, 5) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.3843, 6) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.3843, 7) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3648.3843, 8) == false); // equal digits marked: 123 - REQUIRE(gul17::within_orders(3648.2831, 3649.2843, 2) == true); - REQUIRE(gul17::within_orders(3648.2831, 3649.2843, 3) == true); - REQUIRE(gul17::within_orders(3648.2831, 3649.2843, 4) == false); - REQUIRE(gul17::within_orders(3648.2831, 3649.2843, 5) == false); - REQUIRE(gul17::within_orders(3648.2831, 3649.2843, 6) == false); - REQUIRE(gul17::within_orders(3648.2831, 3649.2843, 7) == false); - REQUIRE(gul17::within_orders(3648.2831, 3649.2843, 8) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3649.2843, 2) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3649.2843, 3) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3649.2843, 4) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3649.2843, 5) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3649.2843, 6) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3649.2843, 7) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3649.2843, 8) == false); // equal digits marked: 12 - REQUIRE(gul17::within_orders(3648.2831, 3638.2843, 2) == true); - REQUIRE(gul17::within_orders(3648.2831, 3638.2843, 3) == false); - REQUIRE(gul17::within_orders(3648.2831, 3638.2843, 4) == false); - REQUIRE(gul17::within_orders(3648.2831, 3638.2843, 5) == false); - REQUIRE(gul17::within_orders(3648.2831, 3638.2843, 6) == false); - REQUIRE(gul17::within_orders(3648.2831, 3638.2843, 7) == false); - REQUIRE(gul17::within_orders(3648.2831, 3638.2843, 8) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3638.2843, 2) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3638.2843, 3) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3638.2843, 4) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3638.2843, 5) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3638.2843, 6) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3638.2843, 7) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3638.2843, 8) == false); // equal digits marked: 1 - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 1) == true); - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 2) == false); - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 3) == false); - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 4) == false); - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 5) == false); - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 6) == false); - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 7) == false); - REQUIRE(gul17::within_orders(3648.2831, 3748.2843, 8) == false); - - REQUIRE(gul17::within_orders(1.01, 1.010, 2) == true); - REQUIRE(gul17::within_orders(1.01, 1.011, 2) == true); - REQUIRE(gul17::within_orders(1.01, 1.012, 2) == true); - REQUIRE(gul17::within_orders(1.01, 1.013, 2) == true); // 0.3 % off - REQUIRE(gul17::within_orders(1.01, 1.024, 2) == false); // 1.4 % off + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 1) == true); + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 2) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 3) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 4) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 5) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 6) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 7) == false); + REQUIRE(GULNS::within_orders(3648.2831, 3748.2843, 8) == false); + + REQUIRE(GULNS::within_orders(1.01, 1.010, 2) == true); + REQUIRE(GULNS::within_orders(1.01, 1.011, 2) == true); + REQUIRE(GULNS::within_orders(1.01, 1.012, 2) == true); + REQUIRE(GULNS::within_orders(1.01, 1.013, 2) == true); // 0.3 % off + REQUIRE(GULNS::within_orders(1.01, 1.024, 2) == false); // 1.4 % off // floating point special values must always fail - REQUIRE(gul17::within_orders(std::nan(""), 1.0, 2) == false); - REQUIRE(gul17::within_orders(1.0, std::nan(""), 2) == false); - REQUIRE(gul17::within_orders(std::numeric_limits::infinity(), 1.0, 2) == false); - REQUIRE(gul17::within_orders(1.0, std::numeric_limits::infinity(), 2) == false); - REQUIRE(gul17::within_orders(-1E10, 1.0, 2) == false); - REQUIRE(gul17::within_orders(-std::numeric_limits::infinity(), 1.0, 2) == false); - REQUIRE(gul17::within_orders(1.0, -std::numeric_limits::infinity(), 2) == false); + REQUIRE(GULNS::within_orders(std::nan(""), 1.0, 2) == false); + REQUIRE(GULNS::within_orders(1.0, std::nan(""), 2) == false); + REQUIRE(GULNS::within_orders(std::numeric_limits::infinity(), 1.0, 2) == false); + REQUIRE(GULNS::within_orders(1.0, std::numeric_limits::infinity(), 2) == false); + REQUIRE(GULNS::within_orders(-1E10, 1.0, 2) == false); + REQUIRE(GULNS::within_orders(-std::numeric_limits::infinity(), 1.0, 2) == false); + REQUIRE(GULNS::within_orders(1.0, -std::numeric_limits::infinity(), 2) == false); // floating point special values must always fail, except when they don't :-> - REQUIRE(gul17::within_orders(1.0, 1.01, std::nan("")) == false); - REQUIRE(gul17::within_orders(1.0, 1.01, std::numeric_limits::infinity()) == false); - REQUIRE(gul17::within_orders(1.0, 1.01, -std::numeric_limits::infinity()) == true); - REQUIRE(gul17::within_orders(1.0, 0.0, 1) == false); - REQUIRE(gul17::within_orders(1.0, 0.0, 0) == false); + REQUIRE(GULNS::within_orders(1.0, 1.01, std::nan("")) == false); + REQUIRE(GULNS::within_orders(1.0, 1.01, std::numeric_limits::infinity()) == false); + REQUIRE(GULNS::within_orders(1.0, 1.01, -std::numeric_limits::infinity()) == true); + REQUIRE(GULNS::within_orders(1.0, 0.0, 1) == false); + REQUIRE(GULNS::within_orders(1.0, 0.0, 0) == false); // Compare zero with zero double a = 0.0; - REQUIRE(gul17::within_orders(a, a, 5) == true); - REQUIRE(gul17::within_orders(static_cast(a), 0.0f, 5) == true); + REQUIRE(GULNS::within_orders(a, a, 5) == true); + REQUIRE(GULNS::within_orders(static_cast(a), 0.0f, 5) == true); // From the Doxygen example with integers - REQUIRE(gul17::within_orders(23736384, 23736228, 5) == true); - REQUIRE(gul17::within_orders(23736384, 23735384, 5) == false); + REQUIRE(GULNS::within_orders(23736384, 23736228, 5) == true); + REQUIRE(GULNS::within_orders(23736384, 23735384, 5) == false); } TEST_CASE("test within_abs()", "[num_util]") { - REQUIRE(gul17::within_abs(1.0, 101.0, 2.0) == false); - REQUIRE(gul17::within_abs(101.0, 1.0, 2.0) == false); - REQUIRE(gul17::within_abs(1.01, 1.02, 0.010001) == true); - REQUIRE(gul17::within_abs(1.01, 1.002, 0.010001) == true); + REQUIRE(GULNS::within_abs(1.0, 101.0, 2.0) == false); + REQUIRE(GULNS::within_abs(101.0, 1.0, 2.0) == false); + REQUIRE(GULNS::within_abs(1.01, 1.02, 0.010001) == true); + REQUIRE(GULNS::within_abs(1.01, 1.002, 0.010001) == true); // crossing zero - REQUIRE(gul17::within_abs(2.0, -2.0, 0.1) == false); - REQUIRE(gul17::within_abs(-1.01, 1.02, 0.1) == false); - REQUIRE(gul17::within_abs(-1.01, -1.02, 0.02) == true); - REQUIRE(gul17::within_abs(-1.01, -1.02, -0.02) == true); + REQUIRE(GULNS::within_abs(2.0, -2.0, 0.1) == false); + REQUIRE(GULNS::within_abs(-1.01, 1.02, 0.1) == false); + REQUIRE(GULNS::within_abs(-1.01, -1.02, 0.02) == true); + REQUIRE(GULNS::within_abs(-1.01, -1.02, -0.02) == true); // equal digits marked: 12345 - REQUIRE(gul17::within_abs(0.6482831, 0.6482843, 0.01) == true); - REQUIRE(gul17::within_abs(0.6482831, 0.6482843, 0.001) == true); - REQUIRE(gul17::within_abs(0.6482831, 0.6482843, 0.0001) == true); - REQUIRE(gul17::within_abs(0.6482831, 0.6482843, 0.00001) == true); - REQUIRE(gul17::within_abs(0.6482831, 0.6482843, 0.000001) == false); - REQUIRE(gul17::within_abs(0.6482831, 0.6482843, 0.0000001) == false); - REQUIRE(gul17::within_abs(0.6482831, 0.6482843, 0.00000001) == false); + REQUIRE(GULNS::within_abs(0.6482831, 0.6482843, 0.01) == true); + REQUIRE(GULNS::within_abs(0.6482831, 0.6482843, 0.001) == true); + REQUIRE(GULNS::within_abs(0.6482831, 0.6482843, 0.0001) == true); + REQUIRE(GULNS::within_abs(0.6482831, 0.6482843, 0.00001) == true); + REQUIRE(GULNS::within_abs(0.6482831, 0.6482843, 0.000001) == false); + REQUIRE(GULNS::within_abs(0.6482831, 0.6482843, 0.0000001) == false); + REQUIRE(GULNS::within_abs(0.6482831, 0.6482843, 0.00000001) == false); // equal digits marked: 1 23456 - REQUIRE(gul17::within_abs(3.6482831, 3.6482843, 0.01) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482843, 0.001) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482843, 0.0001) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482843, 0.00001) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482843, 0.000001) == false); - REQUIRE(gul17::within_abs(3.6482831, 3.6482843, 0.0000001) == false); - REQUIRE(gul17::within_abs(3.6482831, 3.6482843, 0.00000001) == false); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482843, 0.01) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482843, 0.001) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482843, 0.0001) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482843, 0.00001) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482843, 0.000001) == false); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482843, 0.0000001) == false); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482843, 0.00000001) == false); // equal digits marked: 1 23456 - REQUIRE(gul17::within_abs(3.6482831, 3.6482820, 0.01) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482820, 0.001) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482820, 0.0001) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482820, 0.00001) == true); - REQUIRE(gul17::within_abs(3.6482831, 3.6482820, 0.000001) == false); - REQUIRE(gul17::within_abs(3.6482831, 3.6482820, 0.0000001) == false); - REQUIRE(gul17::within_abs(3.6482831, 3.6482820, 0.00000001) == false); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482820, 0.01) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482820, 0.001) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482820, 0.0001) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482820, 0.00001) == true); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482820, 0.000001) == false); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482820, 0.0000001) == false); + REQUIRE(GULNS::within_abs(3.6482831, 3.6482820, 0.00000001) == false); // equal digits marked: 1234 56 - REQUIRE(gul17::within_abs(3648.2831, 3648.2843, 1.0) == true); - REQUIRE(gul17::within_abs(3648.2831, 3648.2843, 0.1) == true); - REQUIRE(gul17::within_abs(3648.2831, 3648.2843, 0.01) == true); - REQUIRE(gul17::within_abs(3648.2831, 3648.2843, 0.001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.2843, 0.0001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.2843, 0.00001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.2843, 0.000001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2843, 1.0) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2843, 0.1) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2843, 0.01) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2843, 0.001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2843, 0.0001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2843, 0.00001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2843, 0.000001) == false); // equal digits marked: 1234 5 - REQUIRE(gul17::within_abs(3648.2831, 3648.2743, 1.0) == true); - REQUIRE(gul17::within_abs(3648.2831, 3648.2743, 0.1) == true); - REQUIRE(gul17::within_abs(3648.2831, 3648.2743, 0.01) == true); - REQUIRE(gul17::within_abs(3648.2831, 3648.2743, 0.001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.2743, 0.0001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.2743, 0.00001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.2743, 0.000001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2743, 1.0) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2743, 0.1) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2743, 0.01) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2743, 0.001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2743, 0.0001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2743, 0.00001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.2743, 0.000001) == false); // equal digits marked: 1234 - REQUIRE(gul17::within_abs(3648.2831, 3648.3843, 1.0) == true); - REQUIRE(gul17::within_abs(3648.2831, 3648.3843, 0.1) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.3843, 0.01) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.3843, 0.001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.3843, 0.0001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.3843, 0.00001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3648.3843, 0.000001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.3843, 1.0) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3648.3843, 0.1) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.3843, 0.01) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.3843, 0.001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.3843, 0.0001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.3843, 0.00001) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3648.3843, 0.000001) == false); - REQUIRE(gul17::within_abs(3648.2831, 3649.2843, 1.0) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3649.2843, 1.0) == false); // equal digits marked: 12 - REQUIRE(gul17::within_abs(3648.2831, 3638.2843, 1000.0) == true); - REQUIRE(gul17::within_abs(3648.2831, 3638.2843, 100.0) == true); - REQUIRE(gul17::within_abs(3648.2831, 3638.2843, 10.0) == true); - REQUIRE(gul17::within_abs(3648.2831, 3638.2823, 10.0) == false); - REQUIRE(gul17::within_abs(3648.2831, 3638.2843, 1.0) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3638.2843, 1000.0) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3638.2843, 100.0) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3638.2843, 10.0) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3638.2823, 10.0) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3638.2843, 1.0) == false); // equal digits marked: 1 - REQUIRE(gul17::within_abs(3648.2831, 3748.2843, 1000.0) == true); - REQUIRE(gul17::within_abs(3648.2831, 3748.2843, 100.0) == false); - REQUIRE(gul17::within_abs(3648.2831, 3748.2843, 10.0) == false); - REQUIRE(gul17::within_abs(3648.2831, 3748.2843, 1.0) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3748.2843, 1000.0) == true); + REQUIRE(GULNS::within_abs(3648.2831, 3748.2843, 100.0) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3748.2843, 10.0) == false); + REQUIRE(GULNS::within_abs(3648.2831, 3748.2843, 1.0) == false); // diff smaller than epsilon() - REQUIRE(gul17::within_abs(1.23E77, 1.23E77, 1.0) == true); + REQUIRE(GULNS::within_abs(1.23E77, 1.23E77, 1.0) == true); // floating point special values must always fail - REQUIRE(gul17::within_abs(std::nan(""), 1.0, 1.0) == false); - REQUIRE(gul17::within_abs(1.0, std::nan(""), 1.0) == false); - REQUIRE(gul17::within_abs(std::numeric_limits::infinity(), 1.0, 1.0) == false); - REQUIRE(gul17::within_abs(1.0, std::numeric_limits::infinity(), 1.0) == false); - REQUIRE(gul17::within_abs(-std::numeric_limits::infinity(), 1.0, 1.0) == false); - REQUIRE(gul17::within_abs(1.0, -std::numeric_limits::infinity(), 1.0) == false); + REQUIRE(GULNS::within_abs(std::nan(""), 1.0, 1.0) == false); + REQUIRE(GULNS::within_abs(1.0, std::nan(""), 1.0) == false); + REQUIRE(GULNS::within_abs(std::numeric_limits::infinity(), 1.0, 1.0) == false); + REQUIRE(GULNS::within_abs(1.0, std::numeric_limits::infinity(), 1.0) == false); + REQUIRE(GULNS::within_abs(-std::numeric_limits::infinity(), 1.0, 1.0) == false); + REQUIRE(GULNS::within_abs(1.0, -std::numeric_limits::infinity(), 1.0) == false); // floating point special values must always fail, except when they don't :-> - REQUIRE(gul17::within_abs(1.0, 2.0, std::nan("")) == false); - REQUIRE(gul17::within_abs(1.0, 2.0, std::numeric_limits::infinity()) == true); + REQUIRE(GULNS::within_abs(1.0, 2.0, std::nan("")) == false); + REQUIRE(GULNS::within_abs(1.0, 2.0, std::numeric_limits::infinity()) == true); // including boundaries - REQUIRE(gul17::within_abs(7.0, 8.0, 1.0) == true); - REQUIRE(gul17::within_abs(8.0, 7.0, 1.0) == true); + REQUIRE(GULNS::within_abs(7.0, 8.0, 1.0) == true); + REQUIRE(GULNS::within_abs(8.0, 7.0, 1.0) == true); // only very few tests on integers - REQUIRE(gul17::within_abs(7, 8, 1) == true); - REQUIRE(gul17::within_abs(8, 7, 1) == true); - REQUIRE(gul17::within_abs(7, 9, 1) == false); - REQUIRE(gul17::within_abs(9, 7, 1) == false); - REQUIRE(gul17::within_abs(7u, 8u, 1u) == true); - REQUIRE(gul17::within_abs(8u, 7u, 1u) == true); - REQUIRE(gul17::within_abs(7u, 9u, 1u) == false); - REQUIRE(gul17::within_abs(9u, 7u, 1u) == false); + REQUIRE(GULNS::within_abs(7, 8, 1) == true); + REQUIRE(GULNS::within_abs(8, 7, 1) == true); + REQUIRE(GULNS::within_abs(7, 9, 1) == false); + REQUIRE(GULNS::within_abs(9, 7, 1) == false); + REQUIRE(GULNS::within_abs(7u, 8u, 1u) == true); + REQUIRE(GULNS::within_abs(8u, 7u, 1u) == true); + REQUIRE(GULNS::within_abs(7u, 9u, 1u) == false); + REQUIRE(GULNS::within_abs(9u, 7u, 1u) == false); // integer wraparound test auto i1 = std::numeric_limits::min() + 10; auto i2 = i1 - 1; auto i3 = 60; - REQUIRE(gul17::within_abs(i1, i2, i3) == true); + REQUIRE(GULNS::within_abs(i1, i2, i3) == true); } TEST_CASE("test within_ulp()", "[num_util]") { - REQUIRE(gul17::within_ulp(3.0f/7.0f, 0.42857143282890319824f, 0)); + REQUIRE(GULNS::within_ulp(3.0f/7.0f, 0.42857143282890319824f, 0)); - REQUIRE(gul17::within_ulp(1.0, 1.0 + 1 * std::numeric_limits::epsilon(), 0) == false); - REQUIRE(gul17::within_ulp(1.0, 1.0 + 1 * std::numeric_limits::epsilon(), 1) == true); - REQUIRE(gul17::within_ulp(1.0, 1.0 - 1 * std::numeric_limits::epsilon(), 0) == false); - REQUIRE(gul17::within_ulp(1.0, 1.0 - 1 * std::numeric_limits::epsilon(), 1) == true); + REQUIRE(GULNS::within_ulp(1.0, 1.0 + 1 * std::numeric_limits::epsilon(), 0) == false); + REQUIRE(GULNS::within_ulp(1.0, 1.0 + 1 * std::numeric_limits::epsilon(), 1) == true); + REQUIRE(GULNS::within_ulp(1.0, 1.0 - 1 * std::numeric_limits::epsilon(), 0) == false); + REQUIRE(GULNS::within_ulp(1.0, 1.0 - 1 * std::numeric_limits::epsilon(), 1) == true); - REQUIRE(gul17::within_ulp(1.0, 1.0 + 3 * std::numeric_limits::epsilon(), 1) == false); - REQUIRE(gul17::within_ulp(1.0, 1.0 + 3 * std::numeric_limits::epsilon(), 2) == false); - REQUIRE(gul17::within_ulp(1.0, 1.0 + 3 * std::numeric_limits::epsilon(), 3) == true); - REQUIRE(gul17::within_ulp(1.0, 1.0 - 3 * std::numeric_limits::epsilon(), 1) == false); - REQUIRE(gul17::within_ulp(1.0, 1.0 - 3 * std::numeric_limits::epsilon(), 2) == false); - REQUIRE(gul17::within_ulp(1.0, 1.0 - 3 * std::numeric_limits::epsilon(), 3) == true); + REQUIRE(GULNS::within_ulp(1.0, 1.0 + 3 * std::numeric_limits::epsilon(), 1) == false); + REQUIRE(GULNS::within_ulp(1.0, 1.0 + 3 * std::numeric_limits::epsilon(), 2) == false); + REQUIRE(GULNS::within_ulp(1.0, 1.0 + 3 * std::numeric_limits::epsilon(), 3) == true); + REQUIRE(GULNS::within_ulp(1.0, 1.0 - 3 * std::numeric_limits::epsilon(), 1) == false); + REQUIRE(GULNS::within_ulp(1.0, 1.0 - 3 * std::numeric_limits::epsilon(), 2) == false); + REQUIRE(GULNS::within_ulp(1.0, 1.0 - 3 * std::numeric_limits::epsilon(), 3) == true); // Typical 4 byte float values allow ~6-7 meaningfull digits, more digits are lost to ULP // The subnormal tests following depend on this representation. @@ -301,45 +301,45 @@ TEST_CASE("test within_ulp()", "[num_util]") static_assert(std::numeric_limits::max_exponent == 128, "Test needs redesign because mantissa/exponent size unexpected"); - REQUIRE(gul17::within_ulp(543.0f, 543.001f, 3) == false); - REQUIRE(gul17::within_ulp(543.0f, 543.0001f, 3) == true); - REQUIRE(gul17::within_ulp(543.0e-36f, 543.001e-36f, 3) == false); - REQUIRE(gul17::within_ulp(543.0e-36f, 543.0001e-36f, 3) == true); - REQUIRE(gul17::within_ulp(543.0e+35f, 543.001e+35f, 3) == false); - REQUIRE(gul17::within_ulp(543.0e+35f, 543.0001e+35f, 3) == true); + REQUIRE(GULNS::within_ulp(543.0f, 543.001f, 3) == false); + REQUIRE(GULNS::within_ulp(543.0f, 543.0001f, 3) == true); + REQUIRE(GULNS::within_ulp(543.0e-36f, 543.001e-36f, 3) == false); + REQUIRE(GULNS::within_ulp(543.0e-36f, 543.0001e-36f, 3) == true); + REQUIRE(GULNS::within_ulp(543.0e+35f, 543.001e+35f, 3) == false); + REQUIRE(GULNS::within_ulp(543.0e+35f, 543.0001e+35f, 3) == true); // Some subnormal numbers, hand selected and checked with dumpfp float f = 1.00000009e-36f; // 1 ULP off REQUIRE(1.0e-36f != f); - REQUIRE(gul17::within_ulp(1.0e-36f, f, 2) == true); - REQUIRE(gul17::within_ulp(1.0e-36f, f, 1) == true); - REQUIRE(gul17::within_ulp(1.0e-36f, f, 0) == false); + REQUIRE(GULNS::within_ulp(1.0e-36f, f, 2) == true); + REQUIRE(GULNS::within_ulp(1.0e-36f, f, 1) == true); + REQUIRE(GULNS::within_ulp(1.0e-36f, f, 0) == false); f = 1.0000002e-36f; // 2 ULP off REQUIRE(1.0e-36f != f); - REQUIRE(gul17::within_ulp(1.0e-36f, f, 2) == true); - REQUIRE(gul17::within_ulp(1.0e-36f, f, 1) == false); - REQUIRE(gul17::within_ulp(1.0e-36f, f, 0) == false); + REQUIRE(GULNS::within_ulp(1.0e-36f, f, 2) == true); + REQUIRE(GULNS::within_ulp(1.0e-36f, f, 1) == false); + REQUIRE(GULNS::within_ulp(1.0e-36f, f, 0) == false); f = 1.000009e-40f; // 1 ULP off REQUIRE(1.0e-40f != f); - REQUIRE(gul17::within_ulp(1.0e-40f, f, 2) == true); - REQUIRE(gul17::within_ulp(1.0e-40f, f, 1) == true); - REQUIRE(gul17::within_ulp(1.0e-40f, f, 0) == false); + REQUIRE(GULNS::within_ulp(1.0e-40f, f, 2) == true); + REQUIRE(GULNS::within_ulp(1.0e-40f, f, 1) == true); + REQUIRE(GULNS::within_ulp(1.0e-40f, f, 0) == false); f = 1.009e-42f; // 6 ULP off; REQUIRE(1.0e-42f != f); - REQUIRE(gul17::within_ulp(1.0e-42f, f, 7) == true); - REQUIRE(gul17::within_ulp(1.0e-42f, f, 6) == true); - REQUIRE(gul17::within_ulp(1.0e-42f, f, 5) == false); - REQUIRE(gul17::within_ulp(1.0e-42f, f, 0) == false); + REQUIRE(GULNS::within_ulp(1.0e-42f, f, 7) == true); + REQUIRE(GULNS::within_ulp(1.0e-42f, f, 6) == true); + REQUIRE(GULNS::within_ulp(1.0e-42f, f, 5) == false); + REQUIRE(GULNS::within_ulp(1.0e-42f, f, 0) == false); auto nan = std::numeric_limits::quiet_NaN(); - REQUIRE(gul17::within_ulp(nan, nan, 10'000'000) == false); - REQUIRE(gul17::within_ulp(std::numeric_limits::infinity(), + REQUIRE(GULNS::within_ulp(nan, nan, 10'000'000) == false); + REQUIRE(GULNS::within_ulp(std::numeric_limits::infinity(), std::numeric_limits::infinity(), 1) == true); - REQUIRE(gul17::within_ulp(-std::numeric_limits::infinity(), + REQUIRE(GULNS::within_ulp(-std::numeric_limits::infinity(), std::numeric_limits::infinity(), 10'000'000) == false); } @@ -372,15 +372,15 @@ class B : public A { TEST_CASE("test clamp()", "[num_util]") { // Simplest test - auto r1 = gul17::clamp(5, 3, 7); - auto r2 = gul17::clamp(2, 3, 7); - auto r3 = gul17::clamp(9, 3, 7); + auto r1 = GULNS::clamp(5, 3, 7); + auto r2 = GULNS::clamp(2, 3, 7); + auto r3 = GULNS::clamp(9, 3, 7); REQUIRE(r1 == 5); REQUIRE(r2 == 3); REQUIRE(r3 == 7); char c = ' '; - auto c1 = gul17::clamp(c, 'a', 'z'); + auto c1 = GULNS::clamp(c, 'a', 'z'); REQUIRE(c1 == 'a'); // assumes ASCII or EBCDIC or any other usual char table // Test with user class, compare by products with lambda @@ -390,11 +390,11 @@ TEST_CASE("test clamp()", "[num_util]") auto v2 = A{ 1.2, 0.6 }; auto v3 = A{ 52.1, 22.8 }; - auto x1 = gul17::clamp(v1, llimit_a, ulimit_a, + auto x1 = GULNS::clamp(v1, llimit_a, ulimit_a, [](auto const& a, auto const& b) { return a.product() < b.product(); }); - auto x2 = gul17::clamp(v2, llimit_a, ulimit_a, + auto x2 = GULNS::clamp(v2, llimit_a, ulimit_a, [](auto const& a, auto const& b) { return a.product() < b.product(); }); - auto x3 = gul17::clamp(v3, llimit_a, ulimit_a, + auto x3 = GULNS::clamp(v3, llimit_a, ulimit_a, [](auto const& a, auto const& b) { return a.product() < b.product(); }); REQUIRE_THAT(x1.product(), WithinAbs(v1.product(), 1e-6)); REQUIRE_THAT(x2.product(), WithinAbs(llimit_a.product(), 1e-6)); @@ -408,19 +408,19 @@ TEST_CASE("test clamp()", "[num_util]") auto v5 = B{ 1.2, 0.6 }; auto v6 = B{ 52.1, 22.8 }; - auto x4 = gul17::clamp(v4, llimit_b, ulimit_b); - auto x5 = gul17::clamp(v5, llimit_b, ulimit_b); - auto x6 = gul17::clamp(v6, llimit_b, ulimit_b); + auto x4 = GULNS::clamp(v4, llimit_b, ulimit_b); + auto x5 = GULNS::clamp(v5, llimit_b, ulimit_b); + auto x6 = GULNS::clamp(v6, llimit_b, ulimit_b); REQUIRE_THAT(x4.product(), WithinAbs(v4.product(), 1e-6)); REQUIRE_THAT(x5.product(), WithinAbs(llimit_b.product(), 1e-6)); REQUIRE_THAT(x6.product(), WithinAbs(ulimit_b.product(), 1e-6)); // Test with user class, compare by member value with lambda - auto x7 = gul17::clamp(v4, llimit_b, ulimit_b, + auto x7 = GULNS::clamp(v4, llimit_b, ulimit_b, [](auto const& a, auto const& b) { return a.val() < b.val(); }); - auto x8 = gul17::clamp(v5, llimit_b, ulimit_b, + auto x8 = GULNS::clamp(v5, llimit_b, ulimit_b, [](auto const& a, auto const& b) { return a.val() < b.val(); }); - auto x9 = gul17::clamp(v6, llimit_b, ulimit_b, + auto x9 = GULNS::clamp(v6, llimit_b, ulimit_b, [](auto const& a, auto const& b) { return a.val() < b.val(); }); REQUIRE_THAT(x7.product(), WithinAbs(llimit_b.product(), 1e-6)); REQUIRE_THAT(x8.product(), WithinAbs(llimit_b.product(), 1e-6)); diff --git a/tests/test_replace.cc b/tests/test_replace.cc index cd6f360..dd66a2d 100644 --- a/tests/test_replace.cc +++ b/tests/test_replace.cc @@ -4,7 +4,7 @@ * \date Created on August 31, 2018 * \brief Part of test suite for string utility functions in the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -22,10 +22,10 @@ #include -#include "gul17/replace.h" +#include "gul20/replace.h" using namespace std::literals; -using namespace gul17; +using namespace GULNS; TEST_CASE("Replace parts of a string in-place", "[replace]") { diff --git a/tests/test_self_containment.cc.in b/tests/test_self_containment.cc.in index 0be937b..bb8c10a 100644 --- a/tests/test_self_containment.cc.in +++ b/tests/test_self_containment.cc.in @@ -4,7 +4,7 @@ * \date Created on August 21, 2019 * \brief Used to check if the individual headers are self-contained * - * \copyright Copyright 2019 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 diff --git a/tests/test_statistics.cc b/tests/test_statistics.cc index 69fdcf9..c66b92d 100644 --- a/tests/test_statistics.cc +++ b/tests/test_statistics.cc @@ -4,7 +4,7 @@ * \date Created on Feb 7, 2019 * \brief Test suite for statistics functions. * - * \copyright Copyright 2019-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -33,19 +33,19 @@ #include #include -#include "gul17/statistics.h" -#include "gul17/substring_checks.h" -#include "gul17/type_name.h" +#include "gul20/statistics.h" +#include "gul20/substring_checks.h" +#include "gul20/type_name.h" -using gul17::accumulate; -using gul17::maximum; -using gul17::mean; -using gul17::median; -using gul17::minimum; -using gul17::min_max; -using gul17::remove_outliers; -using gul17::rms; -using gul17::standard_deviation; +using GULNS::accumulate; +using GULNS::maximum; +using GULNS::mean; +using GULNS::median; +using GULNS::minimum; +using GULNS::min_max; +using GULNS::remove_outliers; +using GULNS::rms; +using GULNS::standard_deviation; using Catch::Matchers::WithinAbs; @@ -124,7 +124,7 @@ TEMPLATE_TEST_CASE("standard_deviation()", "[statistics]", SECTION("Empty container") { std::vector empty; - REQUIRE(std::isnan(static_cast(standard_deviation(empty)))); + REQUIRE(std::isnan(static_cast(standard_deviation(empty)))); auto std_mean = standard_deviation(empty); REQUIRE(std::isnan(std_mean.sigma())); @@ -134,7 +134,7 @@ TEMPLATE_TEST_CASE("standard_deviation()", "[statistics]", SECTION("Container with single element") { std::array arr1{ { 42 } }; - REQUIRE(std::isnan(static_cast(standard_deviation(arr1)))); + REQUIRE(std::isnan(static_cast(standard_deviation(arr1)))); auto std_mean = standard_deviation(arr1); REQUIRE(std::isnan(std_mean.sigma())); @@ -144,7 +144,7 @@ TEMPLATE_TEST_CASE("standard_deviation()", "[statistics]", SECTION("Container with 4 elements") { std::array arr4{ { 1, 2, 3, 4 } }; - REQUIRE_THAT(static_cast(standard_deviation(arr4)), + REQUIRE_THAT(static_cast(standard_deviation(arr4)), WithinAbs(1.29099445, 1e-8)); auto std_mean = standard_deviation(arr4); @@ -239,7 +239,7 @@ TEST_CASE("Container Statistics Tests", "[statistics]") REQUIRE(accumulate(fifo, op_max, acc_state) == state2); // For some reason stuff from standard header seem to be in our namespace, // so we need to specify that we want to use GUL's accumulate rather than std::accumulate - REQUIRE(gul17::accumulate(fifo.begin(), fifo.end(), op_max, acc_state) == state2); + REQUIRE(GULNS::accumulate(fifo.begin(), fifo.end(), op_max, acc_state) == state2); REQUIRE(accumulate(fifo, op_or, acc_state) == (state1 | state2 | state3 | state4 | state5)); REQUIRE(minimum(fifo, accessor) == value2); REQUIRE(maximum(fifo, accessor) == value1); @@ -420,32 +420,32 @@ TEMPLATE_TEST_CASE("ElementAccessor", "[statistics]", auto i = TestType{ }; SECTION("fundamental type access") { auto x = i; - auto ea = gul17::ElementAccessor(); + auto ea = GULNS::ElementAccessor(); using T = decltype(ea(x)); INFO("Shall use const reference:"); - INFO(gul17::type_name()); - INFO(gul17::type_name()); + INFO(GULNS::type_name()); + INFO(GULNS::type_name()); REQUIRE(std::is_const::type>::value); REQUIRE(std::is_reference::value); } SECTION("pointer type access") { auto x = &i; - auto ea = gul17::ElementAccessor(); + auto ea = GULNS::ElementAccessor(); using T = decltype(ea(x)); INFO("Shall use const reference:"); - INFO(gul17::type_name()); - INFO(gul17::type_name()); + INFO(GULNS::type_name()); + INFO(GULNS::type_name()); REQUIRE(std::is_const::type>::value); REQUIRE(std::is_reference::value); } SECTION("user type access") { struct UserType { TestType e; }; auto x = UserType{ 0 }; - auto ea = gul17::ElementAccessor(); + auto ea = GULNS::ElementAccessor(); using T = decltype(ea(x)); INFO("Shall use const reference:"); - INFO(gul17::type_name()); - INFO(gul17::type_name()); + INFO(GULNS::type_name()); + INFO(GULNS::type_name()); REQUIRE(std::is_const::type>::value); REQUIRE(std::is_reference::value); } @@ -462,7 +462,7 @@ TEMPLATE_TEST_CASE("general accumulate()", "[statistics]", v.push_back(9); REQUIRE(std::accumulate(v.cbegin(), v.cend(), TestType{ }, [](TestType a, TestType el) { return a + el; }) == 18); - REQUIRE(gul17::accumulate(v, + REQUIRE(GULNS::accumulate(v, [](TestType a, TestType el) { return a + el; }) == 18); } SECTION("pointer accumulate") { @@ -477,7 +477,7 @@ TEMPLATE_TEST_CASE("general accumulate()", "[statistics]", v.push_back(&d); REQUIRE(std::accumulate(v.cbegin(), v.cend(), TestType{ }, [](TestType accu, TestType* el) { return accu + *el; }) == 14); - REQUIRE(gul17::accumulate(v, + REQUIRE(GULNS::accumulate(v, [](TestType accu, TestType* el) { return accu + *el; }) == 14); } SECTION("user type accumulate") { @@ -494,7 +494,7 @@ TEMPLATE_TEST_CASE("general accumulate()", "[statistics]", v.emplace_back(TestType{ 7 }, true); REQUIRE(std::accumulate(v.cbegin(), v.cend(), TestType{ }, [](TestType accu, UserType const& el) { return accu + el.e; }) == 19); - REQUIRE(gul17::accumulate(v, + REQUIRE(GULNS::accumulate(v, [](TestType accu, UserType const& el) { return accu + el.e; }) == 19); } } diff --git a/tests/test_string_util.cc b/tests/test_string_util.cc index d2a6783..2502231 100644 --- a/tests/test_string_util.cc +++ b/tests/test_string_util.cc @@ -4,7 +4,7 @@ * \date Created on August 11, 2021 * \brief Unit tests for string utility functions. * - * \copyright Copyright 2021-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2021-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -27,17 +27,17 @@ #include -#include "gul17/SmallVector.h" -#include "gul17/string_util.h" +#include "gul20/SmallVector.h" +#include "gul20/string_util.h" -using gul17::hex_string; -using gul17::repeat; +using GULNS::hex_string; +using GULNS::repeat; using namespace std::literals; TEST_CASE("hex_digits", "[string_util]") { - REQUIRE(gul17::hex_digits.size() == 16); + REQUIRE(GULNS::hex_digits.size() == 16); } TEST_CASE("hex_string(Integer)", "[string_util]") @@ -109,14 +109,14 @@ TEST_CASE("hex_string(Container, std::string_view)", "[string_util]") REQUIRE(hex_string(us) == "010000ff"); REQUIRE(hex_string(us, "-") == "0100-00ff"); - gul17::SmallVector sll = { 256, -1, 0 }; + GULNS::SmallVector sll = { 256, -1, 0 }; REQUIRE(hex_string(sll) == "0000000000000100ffffffffffffffff0000000000000000"); REQUIRE(hex_string(sll, "/") == "0000000000000100/ffffffffffffffff/0000000000000000"); } TEST_CASE("null_safe_string(const char*)", "[string_util]") { - using gul17::null_safe_string; + using GULNS::null_safe_string; REQUIRE(null_safe_string(nullptr) == ""); REQUIRE(null_safe_string("") == ""); @@ -126,7 +126,7 @@ TEST_CASE("null_safe_string(const char*)", "[string_util]") TEST_CASE("null_safe_string_view(const char*)", "[string_util]") { - using gul17::null_safe_string_view; + using GULNS::null_safe_string_view; REQUIRE(null_safe_string_view(nullptr) == std::string_view{}); REQUIRE(null_safe_string_view("") == ""sv); @@ -136,7 +136,7 @@ TEST_CASE("null_safe_string_view(const char*)", "[string_util]") TEST_CASE("null_safe_string_view(const char*, std::size_t)", "[string_util]") { - using gul17::null_safe_string_view; + using GULNS::null_safe_string_view; REQUIRE(null_safe_string_view(nullptr, 0ull) == std::string_view{}); REQUIRE(null_safe_string_view(nullptr, 10ull) == std::string_view{}); @@ -159,7 +159,7 @@ TEST_CASE("repeat()", "[string_util]") TEST_CASE("safe_string(const char*, size_t)", "[string_util]") { - using gul17::safe_string; + using GULNS::safe_string; REQUIRE(safe_string(nullptr, 0) == ""); REQUIRE(safe_string(nullptr, 10) == ""); @@ -171,7 +171,7 @@ TEST_CASE("safe_string(const char*, size_t)", "[string_util]") TEST_CASE("safe_string_view(const char*, size_t)", "[string_util]") { - using gul17::safe_string_view; + using GULNS::safe_string_view; REQUIRE(safe_string_view(nullptr, 10) == std::string_view{}); REQUIRE(safe_string_view("", 0) == ""sv); diff --git a/tests/test_substring_checks.cc b/tests/test_substring_checks.cc index 22f1865..3ead170 100644 --- a/tests/test_substring_checks.cc +++ b/tests/test_substring_checks.cc @@ -4,7 +4,7 @@ * \date Created on November 26, 2018 * \brief Test suite for contains(), ends_with(), and starts_with(). * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -22,10 +22,10 @@ #include -#include "gul17/substring_checks.h" +#include "gul20/substring_checks.h" using namespace std::literals; -using namespace gul17; +using namespace GULNS; TEST_CASE("contains(std::string_view, std::string_view)", "[substring_checks]") { diff --git a/tests/test_time_util.cc b/tests/test_time_util.cc index fba1e5a..2ef55a4 100644 --- a/tests/test_time_util.cc +++ b/tests/test_time_util.cc @@ -4,7 +4,7 @@ * \date Created on September 7, 2018 * \brief Test suite for tic(), toc(), and sleep() from the General Utility Library. * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -24,15 +24,15 @@ #include -#include "gul17/time_util.h" -#include "gul17/Trigger.h" +#include "gul20/time_util.h" +#include "gul20/Trigger.h" using namespace std::literals; -using gul17::tic; -using gul17::toc; -using gul17::sleep; -using gul17::Trigger; +using GULNS::tic; +using GULNS::toc; +using GULNS::sleep; +using GULNS::Trigger; SCENARIO("After tic() and sleep(), toc() yields the correct time span", "[time_util]") { diff --git a/tests/test_to_number.cc b/tests/test_to_number.cc index 3eebfc2..78a6cd4 100644 --- a/tests/test_to_number.cc +++ b/tests/test_to_number.cc @@ -4,7 +4,7 @@ * \date Created on July 19, 2019 * \brief Test suite for to_number(). * - * \copyright Copyright 2019-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -31,11 +31,11 @@ #include #include -#include "gul17/to_number.h" -#include "gul17/num_util.h" +#include "gul20/to_number.h" +#include "gul20/num_util.h" using namespace std::literals::string_literals; -using gul17::to_number; +using GULNS::to_number; // Allowed deviation from ideal result in ULP int constexpr long_double_lenience = 3; @@ -163,7 +163,7 @@ TEMPLATE_TEST_CASE("to_number(): Floating point types", "[to_number]", float, do auto const lenience = sizeof(TestType) > sizeof(double) ? long_double_lenience : double_lenience; for (auto const& test : cases) { CAPTURE(test.input); - REQUIRE(gul17::within_ulp(to_number(test.input).value(), + REQUIRE(GULNS::within_ulp(to_number(test.input).value(), TestType(test.output), lenience) == true); } std::array special_cases = {{ @@ -260,7 +260,7 @@ TEMPLATE_TEST_CASE("to_number(): min and subnormal floating point", "[to_number] ss.str(""); ss << num; CAPTURE(ss.str()); - REQUIRE(true == gul17::within_ulp(to_number(ss.str()).value(), num, lenience)); + REQUIRE(true == GULNS::within_ulp(to_number(ss.str()).value(), num, lenience)); } } @@ -273,7 +273,7 @@ TEMPLATE_TEST_CASE("to_number(): max and overflow floating point", "[to_number]" auto numb = ss.str(); auto const lenience = sizeof(TestType) > sizeof(double) ? long_double_lenience : double_lenience; - REQUIRE(true == gul17::within_ulp(to_number(numb).value(), max, lenience)); + REQUIRE(true == GULNS::within_ulp(to_number(numb).value(), max, lenience)); if (numb[0] < '9') ++numb[0]; @@ -298,7 +298,7 @@ TEMPLATE_TEST_CASE("to_number(): lowest and overflow floating point", "[to_numbe auto numb = ss.str(); auto const lenience = sizeof(TestType) > sizeof(double) ? long_double_lenience : double_lenience; - REQUIRE(true == gul17::within_ulp(to_number(numb).value(), lowest, lenience)); + REQUIRE(true == GULNS::within_ulp(to_number(numb).value(), lowest, lenience)); assert(numb[0] == '-'); if (numb[1] < '9') @@ -386,10 +386,10 @@ TEMPLATE_TEST_CASE("to_number(): random round trip conversion", "[to_number]", REQUIRE(std::signbit(num) == std::signbit(*converted)); } else if (not std::isnormal(num)) { CAPTURE("subnormal " + std::to_string(++i_sub)); - REQUIRE(true == gul17::within_ulp(*converted, num, 30)); + REQUIRE(true == GULNS::within_ulp(*converted, num, 30)); } else { CAPTURE("normal " + std::to_string(++i_nor)); - REQUIRE(true == gul17::within_ulp(*converted, num, 3)); + REQUIRE(true == GULNS::within_ulp(*converted, num, 3)); } } } @@ -407,24 +407,24 @@ TEMPLATE_TEST_CASE("to_number(): Convert floating-point values with many leading auto const lenience = 0; auto const test1 = to_number("00000000000000000000000000000000000000000000000000.1"); - REQUIRE(gul17::within_ulp(test1.value(), TestType(0.1l), lenience) == true); + REQUIRE(GULNS::within_ulp(test1.value(), TestType(0.1l), lenience) == true); auto const test2 = to_number("00000000000000000000000000000000000000000000000000.1" "00000000000000000000000000000000000000000000000000"); - REQUIRE(gul17::within_ulp(test2.value(), TestType(0.1l), lenience) == true); + REQUIRE(GULNS::within_ulp(test2.value(), TestType(0.1l), lenience) == true); auto const test3 = to_number("00000000000000000000000000000000000000000000000001" "e000000000000000000000000000000000000000000000000000"); - REQUIRE(gul17::within_ulp(test3.value(), TestType(1.0l), lenience) == true); + REQUIRE(GULNS::within_ulp(test3.value(), TestType(1.0l), lenience) == true); auto const test4 = to_number("00000000000000000000000000000000000000000000000000.1e" "0000000000000000000000000000000000000000000000000"); - REQUIRE(gul17::within_ulp(test4.value(), TestType(0.1l), lenience) == true); + REQUIRE(GULNS::within_ulp(test4.value(), TestType(0.1l), lenience) == true); // higher lenience here: auto const test5 = to_number("0.00000000000000000000000000000000000000000000000001" "e0000000000000000000000000000000000000000000000001"); - REQUIRE(gul17::within_ulp(test5.value(), TestType(1.0e-49l), lenience + 1) == true); + REQUIRE(GULNS::within_ulp(test5.value(), TestType(1.0e-49l), lenience + 1) == true); } /* Disabled because Apple clang 15.0.0 has insufficient constexpr support @@ -473,7 +473,7 @@ TEST_CASE("test pow10()", "[to_number]") int lenience_; int deviation() const { - return std::abs(error_in_ulp(gul17::detail::pow10(exponent_), reference_)); + return std::abs(error_in_ulp(GULNS::detail::pow10(exponent_), reference_)); } }; @@ -545,11 +545,11 @@ TEST_CASE("test pow10()", "[to_number]") } // Overflows... - REQUIRE(std::isinf(gul17::detail::pow10(5000))); - REQUIRE(std::isinf(gul17::detail::pow10(8192))); + REQUIRE(std::isinf(GULNS::detail::pow10(5000))); + REQUIRE(std::isinf(GULNS::detail::pow10(8192))); - REQUIRE(gul17::detail::pow10(-5000) == 0); - REQUIRE(gul17::detail::pow10(-8192) == 0); + REQUIRE(GULNS::detail::pow10(-5000) == 0); + REQUIRE(GULNS::detail::pow10(-8192) == 0); } // vi:ts=4:sw=4:sts=4:et diff --git a/tests/test_tokenize.cc b/tests/test_tokenize.cc index 1c41f7a..d0f4590 100644 --- a/tests/test_tokenize.cc +++ b/tests/test_tokenize.cc @@ -4,7 +4,7 @@ * \date Created on September 3, 2018 * \brief Test suite for tokenize() and tokenize_sv(). * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -33,14 +33,14 @@ #include #include -#include "gul17/case_ascii.h" -#include "gul17/SmallVector.h" -#include "gul17/tokenize.h" +#include "gul20/case_ascii.h" +#include "gul20/SmallVector.h" +#include "gul20/tokenize.h" using namespace std::literals; -using gul17::tokenize; -using gul17::tokenize_sv; +using GULNS::tokenize; +using GULNS::tokenize_sv; #define TEST_BOTH_INTO(tokens) \ @@ -51,7 +51,7 @@ using gul17::tokenize_sv; TEMPLATE_TEST_CASE("tokenize(\"Hello World\")", "[tokenize]", std::vector, std::vector, - (gul17::SmallVector), (gul17::SmallVector)) + (GULNS::SmallVector), (GULNS::SmallVector)) { auto token = std::vector{ tokenize("Hello World"), @@ -70,7 +70,7 @@ TEMPLATE_TEST_CASE("tokenize(\"Hello World\")", "[tokenize]", TEMPLATE_TEST_CASE("tokenize(): \" Hello World\" with odd whitespace", "[tokenize]", std::vector, std::vector, - (gul17::SmallVector), (gul17::SmallVector)) + (GULNS::SmallVector), (GULNS::SmallVector)) { auto token = std::vector{ tokenize("\t Hello\n\rWorld\t\t "), @@ -87,7 +87,7 @@ TEMPLATE_TEST_CASE("tokenize(): \" Hello World\" with odd whitespace", "[tokeniz TEMPLATE_TEST_CASE("tokenize(): custom delimiters and null characters", "[tokenize]", std::vector, std::vector, - (gul17::SmallVector), (gul17::SmallVector)) + (GULNS::SmallVector), (GULNS::SmallVector)) { const auto input = "\t Hel\0lo\n\rWorld\t\t "s; auto token = std::vector{ @@ -106,7 +106,7 @@ TEMPLATE_TEST_CASE("tokenize(): custom delimiters and null characters", "[tokeni TEMPLATE_TEST_CASE("tokenize(): empty delimiter string", "[tokenize]", std::vector, std::vector, - (gul17::SmallVector), (gul17::SmallVector)) + (GULNS::SmallVector), (GULNS::SmallVector)) { auto token = std::vector{ tokenize("Hello World", ""), @@ -177,7 +177,7 @@ TEMPLATE_TEST_CASE("tokenize(\"Hello World\") into std::stack", "[tokenize]", TEMPLATE_TEST_CASE("tokenize(\"Hello World\")'s return type", "[tokenize]", std::vector, std::vector, - (gul17::SmallVector), (gul17::SmallVector), + (GULNS::SmallVector), (GULNS::SmallVector), std::set, std::multiset, std::unordered_set, std::unordered_multiset, std::list, std::deque, std::queue, @@ -203,7 +203,7 @@ TEST_CASE("tokenize(\"Hello World\")'s default return type", "[tokenize]") TEST_CASE("tokenize(\"Hello World\") into std::map", "[tokenize]") { using TestType = std::map; - auto emplace = [](TestType& c, std::string_view sv) { c.emplace(std::string{ sv }, gul17::uppercase_ascii(sv)); }; + auto emplace = [](TestType& c, std::string_view sv) { c.emplace(std::string{ sv }, GULNS::uppercase_ascii(sv)); }; auto token = std::vector{ tokenize("Hello World", " ", emplace), @@ -233,10 +233,10 @@ TEST_CASE("tokenize() into bool", "[tokenize]") present |= (s == to_find); }; - auto is_present = gul17::tokenize("10 3 5 12 ", gul17::default_whitespace_characters, checker); + auto is_present = GULNS::tokenize("10 3 5 12 ", GULNS::default_whitespace_characters, checker); REQUIRE(is_present == false); to_find = "3"s; - is_present = gul17::tokenize("10 3 5 12 ", gul17::default_whitespace_characters, checker); + is_present = GULNS::tokenize("10 3 5 12 ", GULNS::default_whitespace_characters, checker); REQUIRE(is_present == true); } diff --git a/tests/test_trim.cc b/tests/test_trim.cc index 0c6daaf..df30fbe 100644 --- a/tests/test_trim.cc +++ b/tests/test_trim.cc @@ -5,7 +5,7 @@ * \brief Unit tests for trim(), trim_left(), trim_right(), trim_inplace(), * trim_left_inplace(), and trim_right_inplace(). * - * \copyright Copyright 2018-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2018-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -23,14 +23,14 @@ #include -#include "gul17/trim.h" +#include "gul20/trim.h" -using gul17::trim; -using gul17::trim_sv; -using gul17::trim_left; -using gul17::trim_left_sv; -using gul17::trim_right; -using gul17::trim_right_sv; +using GULNS::trim; +using GULNS::trim_sv; +using GULNS::trim_left; +using GULNS::trim_left_sv; +using GULNS::trim_right; +using GULNS::trim_right_sv; using namespace std::literals; diff --git a/tests/test_type_name.cc b/tests/test_type_name.cc index 03108a3..997d13e 100644 --- a/tests/test_type_name.cc +++ b/tests/test_type_name.cc @@ -4,7 +4,7 @@ * \date Created on April 11, 2019 * \brief Test suite for type_name(). * - * \copyright Copyright 2019-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg + * \copyright Copyright 2019-2026 Deutsches Elektronen-Synchrotron (DESY), Hamburg * * 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 @@ -25,7 +25,7 @@ #include #include -#include "gul17/type_name.h" +#include "gul20/type_name.h" using namespace std::literals::string_literals; using Catch::Matchers::ContainsSubstring; @@ -40,16 +40,16 @@ TEST_CASE("Type-name Test", "[type_name]") { SECTION("test some stdlib types") { auto oss = std::ostringstream{ }; - oss << gul17::type_name(); + oss << GULNS::type_name(); REQUIRE_THAT(oss.str(), ContainsSubstring("ostringstream")); oss.str(""); - oss << gul17::type_name(); + oss << GULNS::type_name(); REQUIRE_THAT(oss.str(), ContainsSubstring("basic_string") || ContainsSubstring("std::string")); oss.str(""); - oss << gul17::type_name(); + oss << GULNS::type_name(); REQUIRE_THAT(oss.str(), ContainsSubstring("unsigned")); REQUIRE_THAT(oss.str(), ContainsSubstring("int") or ContainsSubstring("long")); @@ -59,36 +59,36 @@ TEST_CASE("Type-name Test", "[type_name]") } SECTION("test some basic types") { auto oss = std::ostringstream{ }; - oss << gul17::type_name(); + oss << GULNS::type_name(); REQUIRE_THAT(oss.str(), ContainsSubstring("int")); auto& x = "test"; oss.str(""); - oss << gul17::type_name(); + oss << GULNS::type_name(); REQUIRE_THAT(oss.str(), ContainsSubstring("const")); REQUIRE_THAT(oss.str(), ContainsSubstring("char")); REQUIRE_THAT(oss.str(), ContainsSubstring("[5]")); oss.str(""); - oss << gul17::type_name>(); + oss << GULNS::type_name>(); REQUIRE_THAT(oss.str(), ContainsSubstring("const")); REQUIRE_THAT(oss.str(), ContainsSubstring("char")); REQUIRE_THAT(oss.str(), ContainsSubstring("*")); auto f = 2.3f; oss.str(""); - oss << gul17::type_name(); + oss << GULNS::type_name(); REQUIRE_THAT(oss.str(), ContainsSubstring("float")); } SECTION("test some user types") { auto c = clever{ 1 }; auto oss = std::ostringstream{ }; - oss << gul17::type_name(); + oss << GULNS::type_name(); REQUIRE_THAT(oss.str(), ContainsSubstring("clever")); REQUIRE_THAT(oss.str(), ContainsSubstring("int")); } SECTION("test constexpr-ness") { - auto constexpr x = gul17::type_name(); + auto constexpr x = GULNS::type_name(); auto oss = std::ostringstream{ }; oss << x; REQUIRE_THAT(oss.str(), ContainsSubstring("int")); @@ -100,7 +100,7 @@ TEST_CASE("Type-name Test", "[type_name]") // when the following is not commented out: // auto c = clever{ 1 }; - // gul17::FailToInstantiate{}; + // GULNS::FailToInstantiate{}; } } diff --git a/tools/migrate_gul14_to_gul17.bash b/tools/migrate_gul14_to_gul17.bash index cb3b91d..83ffffe 100755 --- a/tools/migrate_gul14_to_gul17.bash +++ b/tools/migrate_gul14_to_gul17.bash @@ -126,7 +126,7 @@ ${mos_subdirs} This function does not exist in GUL17. Manual migration is required. Here's the recommended pattern: -#include +#include auto TypeOfIntegral = gul17::OverloadSet { diff --git a/tools/single_gul b/tools/single_gul index 047c983..90a283f 100755 --- a/tools/single_gul +++ b/tools/single_gul @@ -34,7 +34,7 @@ recurse_header() # It does not parse anything expect #include "" directives (in a primitive manner). headerfile=${1} processed="${processed}:${headerfile}" - + while read -r line; do if [[ "${line}" =~ ^#include ]] ; then file=include/`printf "${line}" | sed 's/.*"\([^"]\+\).*/\1/'` @@ -56,15 +56,15 @@ recurse_header() echo "" > "${outfile}" echo "Collecting all header files..." -recurse_header "include/gul17/gul.h" +recurse_header "include/gul20/gul.h" echo " " `echo "${processed}" | tr -s ':' ' ' | wc \ | tr -s '[:space:]' ' ' | sed 's/[0-9]\+ \([0-9]\+\) [0-9]\+/\1/'` " files" echo "Collecting all code files..." num=0 cat << END >> ${outfile} -#ifndef GUL17_SINGLEFILE_CPP_FILES -#define GUL17_SINGLEFILE_CPP_FILES +#ifndef GUL20_SINGLEFILE_CPP_FILES +#define GUL20_SINGLEFILE_CPP_FILES END for infile in src/*.cc ; do @@ -87,7 +87,7 @@ for infile in src/*.cc ; do done < "${infile}" done cat << END >> ${outfile} -#endif // GUL17_SINGLEFILE_CPP_FILES +#endif // GUL20_SINGLEFILE_CPP_FILES END echo " " "${num}" " files"