diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index ee33897..4bdd26a 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -1,5 +1,3 @@ - - # Copyright 2023 NWChemEx-Project # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ada45bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# Copyright 2025 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +venv/ diff --git a/.licenserc.yaml b/.licenserc.yaml new file mode 100644 index 0000000..b90116c --- /dev/null +++ b/.licenserc.yaml @@ -0,0 +1,31 @@ +# Copyright 2021 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +header: + license: + spdx-id: Apache-2.0 + copyright-owner: NWChemEx-Project + + paths-ignore: + - .github/ + - docs/Makefile + - docs/build/ + - docs/requirements.txt + - cmake/generate_module_docs.cpp.in + - LICENSE + - version.txt + - build/ + - .vscode/ + + comment: never diff --git a/CMakeLists.txt b/CMakeLists.txt index cb84032..7b4fc2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,32 +13,41 @@ # limitations under the License. cmake_minimum_required(VERSION 3.14) +# Downloads common CMake modules used throughout NWChemEx +include(cmake/get_nwx_cmake.cmake) + project(wtf VERSION "1.0.0" LANGUAGES CXX) include(cmake/disable_in_source_builds.cmake) - set(CMAKE_CXX_STANDARD 20) + # TODO: Make these into proper options set(BUILD_TESTING TRUE) set(CMAKE_BUILD_SHARED_LIBS ON) include(cmake/get_dependencies.cmake) +# Define the documentation target +include(nwx_cxx_api_docs) +nwx_cxx_api_docs("include" "src") + +# Build the Library file(GLOB_RECURSE WTF_HEADER_FILES CONFIGURE_DEPENDS include/wtf/*.hpp) file(GLOB_RECURSE WTF_SOURCE_FILES CONFIGURE_DEPENDS src/wtf/*.cpp) add_library(${PROJECT_NAME} ${WTF_SOURCE_FILES}) target_link_libraries(${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} - PUBLIC + PUBLIC $ $ ) + if(${BUILD_TESTING}) include(CTest) get_dependencies(catch2) include(cmake/catch2_tests_from_dir.cmake) catch2_tests_from_dir( - "unit_test_${PROJECT_NAME}" - tests/unit_tests/wtf + "unit_test_${PROJECT_NAME}" + tests/unit_tests/wtf ${PROJECT_NAME} ) -endif() \ No newline at end of file +endif() diff --git a/README.md b/README.md index 526aabb..87bad22 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,38 @@ + + # WeaklyTypedFloat (WTF) This repo is still under heavy development! I am hoping for an alpha release this week. The goal of WTF is to provide a small domain-specific language (DSL) that can -be used to unify interfaces involving floating-point types. Using WTF the user -writes their interfaces in terms of "weakly typed" objects like `Float` and -`FloatBuffer`, and determination of the actual floating-point type is deferred -to runtime. +be used to unify interfaces involving floating-point types. Using WTF the user +writes their interfaces in terms of "weakly typed" objects like `Float` and +`FloatBuffer`, and determination of the actual floating-point type is deferred +to runtime. ## Problem Description Full description (TODO: Add link to the documentation) -Depending on the standard, C++ already natively has a lot of floating-point +Depending on the standard, C++ already natively has a lot of floating-point types, e.g., `float`, `double`, `long double`, `std::complex`, and `std::complex`. This is before considering custom floating-point types, such as those needed for automatic differentiation, or hardware-specific types. When attempting to maintain interfaces with explicit types (such as is required -for C-style interfaces) this leads to a combinatorial explosion in the number -of interfaces. \ No newline at end of file +for C-style interfaces) this leads to a combinatorial explosion in the number +of interfaces. diff --git a/cmake/dependencies/catch2.cmake b/cmake/dependencies/catch2.cmake index a264cb9..e78a197 100644 --- a/cmake/dependencies/catch2.cmake +++ b/cmake/dependencies/catch2.cmake @@ -1,8 +1,22 @@ +# Copyright 2025 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + include_guard() include(FetchContent) FetchContent_Declare( - catch2 + catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2 GIT_TAG "v3.11.0" -) \ No newline at end of file +) diff --git a/cmake/get_dependencies.cmake b/cmake/get_dependencies.cmake index 73c293c..f89bbec 100644 --- a/cmake/get_dependencies.cmake +++ b/cmake/get_dependencies.cmake @@ -1,3 +1,17 @@ +# Copyright 2025 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + include_guard() include(FetchContent) @@ -8,4 +22,4 @@ function(get_dependencies) endforeach() FetchContent_MakeAvailable(${ARGN}) -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/get_nwx_cmake.cmake b/cmake/get_nwx_cmake.cmake new file mode 100644 index 0000000..de8c4bc --- /dev/null +++ b/cmake/get_nwx_cmake.cmake @@ -0,0 +1,31 @@ +# Copyright 2024 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_guard() + +macro(get_nwx_cmake) + include(FetchContent) + FetchContent_Declare( + nwx_cmake + GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake + ) + FetchContent_MakeAvailable(nwx_cmake) + set( + CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${nwx_cmake_SOURCE_DIR}/cmake" + CACHE STRING "" + FORCE + ) +endmacro() + +get_nwx_cmake() diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..899e942 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPROJ = WeaklyTypedFloat +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/source/adding_a_new_type.rst b/docs/source/adding_a_new_type.rst index 58bbc19..c88edb4 100644 --- a/docs/source/adding_a_new_type.rst +++ b/docs/source/adding_a_new_type.rst @@ -1,3 +1,21 @@ +.. Copyright 2025 NWChemEx-Project +.. +.. Licensed under the Apache License, Version 2.0 (the "License"); +.. you may not use this file except in compliance with the License. +.. You may obtain a copy of the License at +.. +.. http://www.apache.org/licenses/LICENSE-2.0 +.. +.. Unless required by applicable law or agreed to in writing, software +.. distributed under the License is distributed on an "AS IS" BASIS, +.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +.. See the License for the specific language governing permissions and +.. limitations under the License. + +############################### +Registering a New Type with WTF +############################### + These are notes on how to register a new type with WTF. .. note:: @@ -10,4 +28,4 @@ These are notes on how to register a new type with WTF. Optional steps: - Specialize Precision -- Ensure implicit conversions are visible to/from your type. \ No newline at end of file +- Ensure implicit conversions are visible to/from your type. diff --git a/docs/source/developer/architecture.rst b/docs/source/developer/architecture.rst index a9f4973..02df490 100644 --- a/docs/source/developer/architecture.rst +++ b/docs/source/developer/architecture.rst @@ -1,3 +1,17 @@ +.. Copyright 2025 NWChemEx-Project +.. +.. Licensed under the Apache License, Version 2.0 (the "License"); +.. you may not use this file except in compliance with the License. +.. You may obtain a copy of the License at +.. +.. http://www.apache.org/licenses/LICENSE-2.0 +.. +.. Unless required by applicable law or agreed to in writing, software +.. distributed under the License is distributed on an "AS IS" BASIS, +.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +.. See the License for the specific language governing permissions and +.. limitations under the License. + ################### Architecture of WTF ################### @@ -9,11 +23,11 @@ FAQs - There's a lot of repetition between ``FloatHolder`` and ``FloatViewHolder``, why can't we combine them? - - In hindsight, we could define a class ``FloatHolderAPI`` that is - templated on the type of ``Float`` that will hold it. ``FloatModel`` would - always derive from ``FloatHolderAPI`` whereas ``FloatViewModel`` - would derive from ``FloatHolderAPI`` or - ``FloatHolderAPI`` depending on the const-ness of the type + - In hindsight, we could define a class ``FloatHolderAPI`` that is + templated on the type of ``Float`` that will hold it. ``FloatModel`` would + always derive from ``FloatHolderAPI`` whereas ``FloatViewModel`` + would derive from ``FloatHolderAPI`` or + ``FloatHolderAPI`` depending on the const-ness of the type argument to ``FloatViewModel``. The holder classes were already written when this realization occurred, so it was not worth the effort to refactor - them. \ No newline at end of file + them. diff --git a/docs/source/developer/index.rst b/docs/source/developer/index.rst index d6f720c..f87aacb 100644 --- a/docs/source/developer/index.rst +++ b/docs/source/developer/index.rst @@ -18,7 +18,7 @@ Developer Documentation .. toctree:: :maxdepth: 2 - :caption: Contents + :caption: Design and Technical Documents statement_of_need scope diff --git a/docs/source/developer/scope.rst b/docs/source/developer/scope.rst index 9d97929..55d2bfe 100644 --- a/docs/source/developer/scope.rst +++ b/docs/source/developer/scope.rst @@ -32,24 +32,24 @@ erased FP value. In practice users will rarely want to work with a single value so we will also need to provide a way to work with collections of these values, of particular note is that users will want to work with collections of these values that are stored in contiguous memory. To provide an object-oriented API, -it must be possible for the user to grab an element from the collection in a -way that the element is assignable, but still stored in the full collection -(e.g., think of it as a reference or view of the element). Similarly, it must -be possible to grab a sub-collection of the full collection in a way that the +it must be possible for the user to grab an element from the collection in a +way that the element is assignable, but still stored in the full collection +(e.g., think of it as a reference or view of the element). Similarly, it must +be possible to grab a sub-collection of the full collection in a way that the sub-collection is assignable, but still stored in the full collection. The latter also enables the user to interface already allocated memory with WTF. In summary: - ``wtf::Float`` class that holds a type-erased floating point value. Owns the - underlying value. + underlying value. - ``wtf::FloatBuffer`` class that acts like it holds a series of ``wtf::Float`` objects, but actually unwraps the underlying type into contiguous memory. Owns - the underlying memory. + the underlying memory. - ``wtf::FloatView`` class that acts like it is aliasing a ``wtf::Float`` object, but actually wraps a pointer to the raw memory. -- ``wtf::FloatBufferView`` class that acts like an alias to a - ``wtf::FloatBuffer`` object, but actually wraps pointer(s) to the contiguous +- ``wtf::FloatBufferView`` class that acts like an alias to a + ``wtf::FloatBuffer`` object, but actually wraps pointer(s) to the contiguous memory. In practice, we will also need ``const`` versions of the view classes (views @@ -67,10 +67,11 @@ Under typical circumstances all C++ objects should provide: - Copy and move assignment operators. - Deep copy for objects that own memory. Shallow for those that alias. - Equality/Inequality operators. + - Exact equality. Good for testing that state is set correctly. Not used for checking results of numerical calculations (vide infra). -Since these will be numerical types it will also be nice if our objects +Since these will be numerical types it will also be nice if our objects provided: - Operations to establish order (e.g., ``<``, ``>``, etc...). @@ -93,6 +94,7 @@ Maybe We Support **************** - Element-wise arithmetic operations (e.g., ``+``, ``-``, ``*``, ``/``). + - Implementing these in a performant manner may require us to use specialized math libraries, which in turn makes this start to look like linear - algebra. \ No newline at end of file + algebra. diff --git a/docs/source/index.rst b/docs/source/index.rst index b2248b9..d407148 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -24,10 +24,10 @@ working with floating-point (FP) numbers in a type-erased manner. :caption: Contents developer/index + adding_a_new_type .. toctree:: :maxdepth: 2 :caption: APIs: - module_api/index C++ API diff --git a/include/wtf/buffer/buffer.hpp b/include/wtf/buffer/buffer.hpp index c59945d..787f779 100644 --- a/include/wtf/buffer/buffer.hpp +++ b/include/wtf/buffer/buffer.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -9,4 +25,4 @@ /** @brief Contains classes and functions for interacting with type-erased * buffers */ -namespace wtf::buffer {} \ No newline at end of file +namespace wtf::buffer {} diff --git a/include/wtf/buffer/buffer_view.hpp b/include/wtf/buffer/buffer_view.hpp index 5dc8f8a..50690c5 100644 --- a/include/wtf/buffer/buffer_view.hpp +++ b/include/wtf/buffer/buffer_view.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -8,8 +24,8 @@ namespace wtf::buffer { /** @brief A type-erased buffer of floating-point values. * - * @tparam FloatType The type of buffer this is acing like. Must satisfy the - * concepts::FloatBuffer concept. + * @tparam FloatType The type of the elements in the buffer. Must satisfy the + * concepts::WTFFloat concept. * * This class aliases an existing buffer and allows the user to interact with * it as if it were a FloatBuffer object. @@ -399,4 +415,4 @@ std::span contiguous_buffer_cast(BufferView& buffer) { return buffer.template value(); } -} // namespace wtf::buffer \ No newline at end of file +} // namespace wtf::buffer diff --git a/include/wtf/buffer/detail_/buffer_holder.hpp b/include/wtf/buffer/detail_/buffer_holder.hpp index 2b33b92..b48b06d 100644 --- a/include/wtf/buffer/detail_/buffer_holder.hpp +++ b/include/wtf/buffer/detail_/buffer_holder.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -102,6 +118,14 @@ class BufferHolder { */ const_rtti_reference type() const { return m_rtti_; } + /** @brief Are the held elements read-only? + * + * @return true if the held elements are read-only, false otherwise. + * + * @throw None No-throw guarantee. + */ + bool is_const() const noexcept { return is_const_(); } + /** @brief Are the elements in the buffer contiguous? * * This method indicates whether the held buffer stores its elements @@ -152,6 +176,9 @@ class BufferHolder { /// The size of the held buffer virtual size_type size_() const noexcept = 0; + /// Does the derived class hold read-only data + virtual bool is_const_() const noexcept = 0; + /// Does the derived class store the buffer contiguously in memory? virtual bool is_contiguous_() const = 0; @@ -174,4 +201,4 @@ inline void BufferHolder::assert_in_range(size_type index) const { } } -} // namespace wtf::buffer::detail_ \ No newline at end of file +} // namespace wtf::buffer::detail_ diff --git a/include/wtf/buffer/detail_/buffer_view_holder.hpp b/include/wtf/buffer/detail_/buffer_view_holder.hpp index 1632d97..1c602ec 100644 --- a/include/wtf/buffer/detail_/buffer_view_holder.hpp +++ b/include/wtf/buffer/detail_/buffer_view_holder.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -201,4 +217,4 @@ void BufferViewHolder::assert_in_range(size_type index) const { } } -} // namespace wtf::buffer::detail_ \ No newline at end of file +} // namespace wtf::buffer::detail_ diff --git a/include/wtf/buffer/detail_/contiguous_model.hpp b/include/wtf/buffer/detail_/contiguous_model.hpp index 9dd7194..1379628 100644 --- a/include/wtf/buffer/detail_/contiguous_model.hpp +++ b/include/wtf/buffer/detail_/contiguous_model.hpp @@ -1,6 +1,24 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once +#include #include #include +#include #include namespace wtf::buffer::detail_ { @@ -39,7 +57,7 @@ class ContiguousModel : public BufferHolder { ///@} /// Type used to manage the floating-point buffer - using vector_type = std::vector; + using vector_type = std::vector>; /** @brief Takes ownership of @p buffer. * @@ -106,6 +124,28 @@ class ContiguousModel : public BufferHolder { */ const_pointer data() const { return m_buffer_.data(); } + /** @brief Returns the wrapped data as a std::span. + * + * Starting with C++20 this is the preferred way to access raw contiguous + * buffers. + * + * @return A std::span wrapping the underlying buffer. + * + * @throw None No-throw guarantee. + */ + auto span() { return std::span(data(), size()); } + + /** @brief Returns the wrapped data as a std::span. + * + * This method is the same as the non-const version except that it ensures + * the resulting span is read-only. + * + * @return A std::span wrapping the underlying buffer. + * + * @throw None No-throw guarantee. + */ + auto span() const { return std::span(data(), size()); } + /** @brief Compares the elements in the buffer for exact equality. * * Value equal is defined as having the same elements in the same order. @@ -139,6 +179,11 @@ class ContiguousModel : public BufferHolder { /// Calls vector_type's size() size_type size_() const noexcept override { return m_buffer_.size(); } + /// Checks FloatType for "const" + bool is_const_() const noexcept override { + return std::is_const_v; + } + /// *this always store data contiguously (unless FloatType == bool) bool is_contiguous_() const override { return true; } @@ -154,4 +199,42 @@ class ContiguousModel : public BufferHolder { vector_type m_buffer_; }; -} // namespace wtf::buffer::detail_ \ No newline at end of file +/** @brief Wraps the process of calling a visitor with zero or more + * ContiguousModel objects. + * + * @relates ContiguousModel + * + * @tparam TupleType A std::tuple of floating-point types to try. Must be + * explicitly provided by the user. + * @tparam Visitor The type of the visitor to call. Must be a callable object + * capable of accepting `std::span` objects for each + * possible T in @p TupleType. Will be inferred by the + * compiler. + * @tparam Args The types of the arguments to forward to the visitor. Each + * is expected to be downcastable to a ContiguousModel holding + * one of the types in @p TupleType. Will be inferred by the + * compiler. + * + * @param[in] visitor The visitor to call with the unwrapped std::span + * objects. + * @param[in] args The ContiguousModel objects to unwrap and pass to the + * visitor. + * + * @return The return value of calling @p visitor with the unwrapped + * std::span objects. + * + * @throw std::runtime_error if any of the @p args cannot be downcast to a + * ContiguousModel holding one of the types in + * @p TupleType. Strong throw guarantee. + * @throw ??? if calling @p visitor throws. Same throw guarantee. + */ +template +auto visit_contiguous_model(Visitor&& visitor, Args&&... args) { + auto lambda = [=](auto&&... inner_args) { + return visitor(inner_args.span()...); + }; + return wtf::detail_::dispatch( + lambda, std::forward(args)...); +} + +} // namespace wtf::buffer::detail_ diff --git a/include/wtf/buffer/detail_/contiguous_view_model.hpp b/include/wtf/buffer/detail_/contiguous_view_model.hpp index 50894c0..0e5520d 100644 --- a/include/wtf/buffer/detail_/contiguous_view_model.hpp +++ b/include/wtf/buffer/detail_/contiguous_view_model.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -194,4 +210,4 @@ class ContiguousViewModel span_type m_buffer_; }; -} // namespace wtf::buffer::detail_ \ No newline at end of file +} // namespace wtf::buffer::detail_ diff --git a/include/wtf/buffer/float_buffer.hpp b/include/wtf/buffer/float_buffer.hpp index cd5d381..d7c4f9f 100644 --- a/include/wtf/buffer/float_buffer.hpp +++ b/include/wtf/buffer/float_buffer.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -216,17 +232,18 @@ class FloatBuffer { template std::span value() { - auto& model = downcast_(); - return std::span(model.data(), model.size()); + return downcast_().span(); } template std::span value() const { - const auto& model = downcast_(); - return std::span(model.data(), model.size()); + return downcast_().span(); } private: + template + friend auto visit_contiguous_buffer(Visitor&& visitor, Args&&... args); + template auto& downcast_() { using model_type = detail_::ContiguousModel; @@ -276,6 +293,41 @@ std::span contiguous_buffer_cast(FloatBuffer& buffer) { return buffer.template value(); } +/** @brief Wraps the process of calling a visitor with zero or more + * FloatBuffer objects. + * + * @relates FloatBuffer + * + * @tparam TupleType A std::tuple of floating-point types to try. Must be + * explicitly provided by the user. + * @tparam Visitor The type of the visitor to call. Must be a callable object + * capable of accepting `std::span` objects for each + * possible T in @p TupleType. Will be inferred by the + * compiler. + * @tparam Args The types of the arguments to forward to the visitor. Each + * is expected to be downcastable to a ContiguousModel holding + * one of the types in @p TupleType. Will be inferred by the + * compiler. + * + * @param[in] visitor The visitor to call with the unwrapped std::span + * objects. + * @param[in] args The ContiguousModel objects to unwrap and pass to the + * visitor. + * + * @return The return value of calling @p visitor with the unwrapped + * std::span objects. + * + * @throw std::runtime_error if any of the @p args cannot be downcast to a + * ContiguousModel holding one of the types in + * @p TupleType. Strong throw guarantee. + * @throw ??? if calling @p visitor throws. Same throw guarantee. + */ +template +auto visit_contiguous_buffer(Visitor&& visitor, Args&&... args) { + return detail_::visit_contiguous_model( + std::forward(visitor), *args.m_pholder_...); +} + // ----------------------------------------------------------------------------- // Out of line inline implementations // ----------------------------------------------------------------------------- @@ -295,4 +347,4 @@ FloatBuffer& FloatBuffer::operator=(const FloatBuffer& other) { return *this; } -} // namespace wtf::buffer \ No newline at end of file +} // namespace wtf::buffer diff --git a/include/wtf/concepts/concepts.hpp b/include/wtf/concepts/concepts.hpp index 83d7f8a..8ad9481 100644 --- a/include/wtf/concepts/concepts.hpp +++ b/include/wtf/concepts/concepts.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -5,4 +21,4 @@ #include /// Contains concepts used throughout the WTF library -namespace wtf::concepts {} \ No newline at end of file +namespace wtf::concepts {} diff --git a/include/wtf/concepts/float_buffer.hpp b/include/wtf/concepts/float_buffer.hpp index 95f3d66..dfb036a 100644 --- a/include/wtf/concepts/float_buffer.hpp +++ b/include/wtf/concepts/float_buffer.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -12,4 +28,4 @@ template concept FloatBuffer = std::is_same_v || std::is_same_v; -} // namespace wtf::concepts \ No newline at end of file +} // namespace wtf::concepts diff --git a/include/wtf/concepts/floating_point.hpp b/include/wtf/concepts/floating_point.hpp index f1f1617..0496fe3 100644 --- a/include/wtf/concepts/floating_point.hpp +++ b/include/wtf/concepts/floating_point.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -37,4 +53,4 @@ concept FloatingPoint = template concept ConstFloatingPoint = FloatingPoint && ConstQualified; -} // namespace wtf::concepts \ No newline at end of file +} // namespace wtf::concepts diff --git a/include/wtf/concepts/iterator.hpp b/include/wtf/concepts/iterator.hpp index 6a6a6ac..9995848 100644 --- a/include/wtf/concepts/iterator.hpp +++ b/include/wtf/concepts/iterator.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -12,4 +28,4 @@ template concept FPIterator = FloatingPoint::value_type>; -} // namespace wtf::concepts \ No newline at end of file +} // namespace wtf::concepts diff --git a/include/wtf/concepts/modifiers.hpp b/include/wtf/concepts/modifiers.hpp index 7f7f0d7..bf1bd27 100644 --- a/include/wtf/concepts/modifiers.hpp +++ b/include/wtf/concepts/modifiers.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -64,4 +80,4 @@ template concept Unmodified = !ConstQualified && !VolatileQualified && !IsPointer && !IsReference; -} // namespace wtf::concepts \ No newline at end of file +} // namespace wtf::concepts diff --git a/include/wtf/concepts/wtf_float.hpp b/include/wtf/concepts/wtf_float.hpp index 0398abf..969dec7 100644 --- a/include/wtf/concepts/wtf_float.hpp +++ b/include/wtf/concepts/wtf_float.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -12,4 +28,4 @@ template concept WTFFloat = std::is_same_v || std::is_same_v; -} // namespace wtf::concepts \ No newline at end of file +} // namespace wtf::concepts diff --git a/include/wtf/detail_/dispatcher.hpp b/include/wtf/detail_/dispatcher.hpp index 3945ab0..e316358 100644 --- a/include/wtf/detail_/dispatcher.hpp +++ b/include/wtf/detail_/dispatcher.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -286,4 +302,4 @@ auto dispatch(FxnType&& fxn, HolderTypes&&... other_holders) { } } -} // namespace wtf::detail_ \ No newline at end of file +} // namespace wtf::detail_ diff --git a/include/wtf/detail_/downcaster.hpp b/include/wtf/detail_/downcaster.hpp index c557a78..fe20282 100644 --- a/include/wtf/detail_/downcaster.hpp +++ b/include/wtf/detail_/downcaster.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -109,4 +125,4 @@ auto const_downcaster(T&& holder) { return downcast_impl<0, variant_type>(std::forward(holder)); } -} // namespace wtf::detail_ \ No newline at end of file +} // namespace wtf::detail_ diff --git a/include/wtf/detail_/variant_from_tuple.hpp b/include/wtf/detail_/variant_from_tuple.hpp index 7fb7c0b..ddf2697 100644 --- a/include/wtf/detail_/variant_from_tuple.hpp +++ b/include/wtf/detail_/variant_from_tuple.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -40,7 +56,7 @@ template typename ModelType, concepts::UnmodifiedFloatingPoint... Args> struct VariantFromTuple> { /// How each ModelType is represented in the variant - template + template using model_type = ModelType*; /// A variant where the ModelType's types are unqualified @@ -78,7 +94,7 @@ template typename ModelType, concepts::UnmodifiedFloatingPoint... Args> struct ConstVariantFromTuple> { /// How each ModelType is represented in the variant - template + template using model_type = const ModelType*; /// A variant where the ModelType's types are unqualified @@ -88,4 +104,4 @@ struct ConstVariantFromTuple> { using cvalue = std::variant...>; }; -} // namespace wtf::detail_ \ No newline at end of file +} // namespace wtf::detail_ diff --git a/include/wtf/forward.hpp b/include/wtf/forward.hpp index 6d1a5cf..5966061 100644 --- a/include/wtf/forward.hpp +++ b/include/wtf/forward.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once namespace wtf { @@ -10,4 +26,4 @@ namespace buffer { class FloatBuffer; } -} // namespace wtf \ No newline at end of file +} // namespace wtf diff --git a/include/wtf/fp/detail_/float_holder.hpp b/include/wtf/fp/detail_/float_holder.hpp index e897a9b..9101d46 100644 --- a/include/wtf/fp/detail_/float_holder.hpp +++ b/include/wtf/fp/detail_/float_holder.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -121,4 +137,4 @@ class FloatHolder { type_info m_type_; }; -} // namespace wtf::fp::detail_ \ No newline at end of file +} // namespace wtf::fp::detail_ diff --git a/include/wtf/fp/detail_/float_model.hpp b/include/wtf/fp/detail_/float_model.hpp index f9d5663..f39af0b 100644 --- a/include/wtf/fp/detail_/float_model.hpp +++ b/include/wtf/fp/detail_/float_model.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include // for std::move, std::swap #include @@ -175,4 +191,4 @@ class FloatModel : public FloatHolder { value_type value_; }; -} // namespace wtf::fp::detail_ \ No newline at end of file +} // namespace wtf::fp::detail_ diff --git a/include/wtf/fp/detail_/float_view_holder.hpp b/include/wtf/fp/detail_/float_view_holder.hpp index cf8c24b..1c080b5 100644 --- a/include/wtf/fp/detail_/float_view_holder.hpp +++ b/include/wtf/fp/detail_/float_view_holder.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -196,4 +212,4 @@ void FloatViewHolder::change_value(const FloatViewHolder& other) { } } -} // namespace wtf::fp::detail_ \ No newline at end of file +} // namespace wtf::fp::detail_ diff --git a/include/wtf/fp/detail_/float_view_model.hpp b/include/wtf/fp/detail_/float_view_model.hpp index 58415da..8674579 100644 --- a/include/wtf/fp/detail_/float_view_model.hpp +++ b/include/wtf/fp/detail_/float_view_model.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include // for std::move, std::swap #include @@ -210,4 +226,4 @@ class FloatViewModel pointer m_pvalue_; }; -} // namespace wtf::fp::detail_ \ No newline at end of file +} // namespace wtf::fp::detail_ diff --git a/include/wtf/fp/float.hpp b/include/wtf/fp/float.hpp index 4e8d3d7..3d59fc6 100644 --- a/include/wtf/fp/float.hpp +++ b/include/wtf/fp/float.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -183,7 +199,7 @@ class Float { */ template bool operator==(T lhs, const Float& rhs) { - return rhs == lhs; + return Float(lhs) == rhs; } /** @brief Allows floating-point objects to be compared to Floats. @@ -206,7 +222,7 @@ bool operator==(T lhs, const Float& rhs) { */ template bool operator!=(T lhs, const Float& rhs) { - return !(rhs == lhs); + return !(lhs == rhs); } /** @brief Helps create a Float object from an object of type @p T. @@ -274,4 +290,4 @@ T float_cast(Float& f) { } return *pderived->data(); } -} // namespace wtf::fp \ No newline at end of file +} // namespace wtf::fp diff --git a/include/wtf/fp/float_view.hpp b/include/wtf/fp/float_view.hpp index f653653..c28b21e 100644 --- a/include/wtf/fp/float_view.hpp +++ b/include/wtf/fp/float_view.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -440,4 +456,4 @@ T FloatView::value() const { return *pderived->data(); } -} // namespace wtf::fp \ No newline at end of file +} // namespace wtf::fp diff --git a/include/wtf/fp/fp.hpp b/include/wtf/fp/fp.hpp index b3494a8..f88bdd6 100644 --- a/include/wtf/fp/fp.hpp +++ b/include/wtf/fp/fp.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -8,4 +24,4 @@ * `float` is a protected keyword in C++, so we use `fp` (floating point) * instead. */ -namespace wtf::fp {} \ No newline at end of file +namespace wtf::fp {} diff --git a/include/wtf/rtti/detail_/type_holder.hpp b/include/wtf/rtti/detail_/type_holder.hpp index bdb346d..ccc407f 100644 --- a/include/wtf/rtti/detail_/type_holder.hpp +++ b/include/wtf/rtti/detail_/type_holder.hpp @@ -1,6 +1,23 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include +#include #include #include #include @@ -199,4 +216,4 @@ bool TypeHolder::is_implicitly_convertible_to(const TypeHolder& other) const { return wtf::detail_::dispatch(lambda, *this, other); } -} // namespace wtf::rtti::detail_ \ No newline at end of file +} // namespace wtf::rtti::detail_ diff --git a/include/wtf/rtti/detail_/type_model.hpp b/include/wtf/rtti/detail_/type_model.hpp index 3f945e9..df64343 100644 --- a/include/wtf/rtti/detail_/type_model.hpp +++ b/include/wtf/rtti/detail_/type_model.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -82,4 +98,4 @@ class TypeModel : public TypeHolder { string_type m_qualified_name_; }; -} // namespace wtf::rtti::detail_ \ No newline at end of file +} // namespace wtf::rtti::detail_ diff --git a/include/wtf/rtti/rtti.hpp b/include/wtf/rtti/rtti.hpp index 14b6628..711c7ed 100644 --- a/include/wtf/rtti/rtti.hpp +++ b/include/wtf/rtti/rtti.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -8,4 +24,4 @@ * This namespace contains classes and functions that facilitate runtime type * information manipulation. */ -namespace wtf::rtti {} \ No newline at end of file +namespace wtf::rtti {} diff --git a/include/wtf/rtti/type_info.hpp b/include/wtf/rtti/type_info.hpp index ff290f7..35a4d41 100644 --- a/include/wtf/rtti/type_info.hpp +++ b/include/wtf/rtti/type_info.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -201,4 +217,4 @@ TypeInfo wtf_typeid() { return TypeInfo(model.get_model()); } -} // namespace wtf::rtti \ No newline at end of file +} // namespace wtf::rtti diff --git a/include/wtf/type_traits/float_traits.hpp b/include/wtf/type_traits/float_traits.hpp index 6076912..4abab52 100644 --- a/include/wtf/type_traits/float_traits.hpp +++ b/include/wtf/type_traits/float_traits.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -42,4 +58,4 @@ struct float_traits { std::is_const_v>; }; -} // namespace wtf::type_traits \ No newline at end of file +} // namespace wtf::type_traits diff --git a/include/wtf/type_traits/is_convertible.hpp b/include/wtf/type_traits/is_convertible.hpp index bfd7104..9750473 100644 --- a/include/wtf/type_traits/is_convertible.hpp +++ b/include/wtf/type_traits/is_convertible.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -27,4 +43,4 @@ template inline constexpr bool is_convertible_v = IsConvertible::value; -} // namespace wtf::type_traits \ No newline at end of file +} // namespace wtf::type_traits diff --git a/include/wtf/type_traits/is_floating_point.hpp b/include/wtf/type_traits/is_floating_point.hpp index 86c4884..e58aacf 100644 --- a/include/wtf/type_traits/is_floating_point.hpp +++ b/include/wtf/type_traits/is_floating_point.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -14,13 +30,14 @@ namespace wtf::type_traits { * * The primary template contains a static boolean member `value` that is set * to true if `std::is_floating_point_v` is true, and false otherwise. - */ -template struct IsFloatingPoint { - constexpr static bool value = std::is_floating_point_v; + */ +template +struct IsFloatingPoint { + constexpr static bool value = std::is_floating_point_v; }; /// Convenience variable template for grabbing `IsFloatingPoint::value` -template +template constexpr bool is_floating_point_v = IsFloatingPoint::value; -} // namespace wtf::type_traits \ No newline at end of file +} // namespace wtf::type_traits diff --git a/include/wtf/type_traits/precision.hpp b/include/wtf/type_traits/precision.hpp index a8e511b..bb6cd45 100644 --- a/include/wtf/type_traits/precision.hpp +++ b/include/wtf/type_traits/precision.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -52,4 +68,4 @@ struct Precision { template constexpr auto precision_v = Precision::value; -} // namespace wtf::type_traits \ No newline at end of file +} // namespace wtf::type_traits diff --git a/include/wtf/type_traits/tuple_append.hpp b/include/wtf/type_traits/tuple_append.hpp index f47948f..168fd73 100644 --- a/include/wtf/type_traits/tuple_append.hpp +++ b/include/wtf/type_traits/tuple_append.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -45,4 +61,4 @@ struct TupleAppend, std::tuple> { template using tuple_append_t = typename TupleAppend::type; -} // namespace wtf::type_traits \ No newline at end of file +} // namespace wtf::type_traits diff --git a/include/wtf/type_traits/type_name.hpp b/include/wtf/type_traits/type_name.hpp index c1d186c..6d0313a 100644 --- a/include/wtf/type_traits/type_name.hpp +++ b/include/wtf/type_traits/type_name.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -45,4 +61,4 @@ struct TypeName { template constexpr auto type_name_v = TypeName::value; -} // namespace wtf::type_traits \ No newline at end of file +} // namespace wtf::type_traits diff --git a/include/wtf/type_traits/type_traits.hpp b/include/wtf/type_traits/type_traits.hpp index 01db31c..434c33b 100644 --- a/include/wtf/type_traits/type_traits.hpp +++ b/include/wtf/type_traits/type_traits.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -26,4 +42,7 @@ struct TypeName { \ static constexpr const char* value = #T; \ }; \ - } // namespace wtf::type_traits \ No newline at end of file + } // namespace wtf::type_traits + +/// @brief Namespace for type traits provided by WTF. +namespace wtf::type_traits {} diff --git a/include/wtf/types.hpp b/include/wtf/types.hpp index 8add3c7..e91ccd9 100644 --- a/include/wtf/types.hpp +++ b/include/wtf/types.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include @@ -5,4 +21,4 @@ namespace wtf { /// A tuple holding C++'s default, real, floating-point types using default_fp_types = std::tuple; -} // namespace wtf \ No newline at end of file +} // namespace wtf diff --git a/include/wtf/wtf.hpp b/include/wtf/wtf.hpp index 4b8e3a5..7fd3ee3 100644 --- a/include/wtf/wtf.hpp +++ b/include/wtf/wtf.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include #include @@ -9,4 +25,4 @@ /** @brief Contains all public-facing APIs for the Weakly Typed Float library. * */ -namespace wtf {} \ No newline at end of file +namespace wtf {} diff --git a/src/wtf/fp/detail_/float_holder.cpp b/src/wtf/fp/detail_/float_holder.cpp index 679fc38..4b22d6b 100644 --- a/src/wtf/fp/detail_/float_holder.cpp +++ b/src/wtf/fp/detail_/float_holder.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include namespace wtf::fp::detail_ { @@ -11,4 +27,4 @@ void FloatHolder::change_value(const FloatHolder& other) { } } -} // namespace wtf::fp::detail_ \ No newline at end of file +} // namespace wtf::fp::detail_ diff --git a/src/wtf/fp/float.cpp b/src/wtf/fp/float.cpp index 4ae4b5a..f0b96ac 100644 --- a/src/wtf/fp/float.cpp +++ b/src/wtf/fp/float.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include namespace wtf::fp { @@ -7,4 +23,4 @@ Float& Float::operator=(const Float& other) { return *this; } -} // namespace wtf::fp \ No newline at end of file +} // namespace wtf::fp diff --git a/src/wtf/rtti/detail_/type_holder.cpp b/src/wtf/rtti/detail_/type_holder.cpp index b53f8f8..ca385a9 100644 --- a/src/wtf/rtti/detail_/type_holder.cpp +++ b/src/wtf/rtti/detail_/type_holder.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include #include @@ -8,4 +24,4 @@ using holder_pointer = TypeHolder::holder_pointer; std::map TypeHolder::m_registry_; -} // namespace wtf::rtti::detail_ \ No newline at end of file +} // namespace wtf::rtti::detail_ diff --git a/src/wtf/rtti/type_info.cpp b/src/wtf/rtti/type_info.cpp index ad7e868..b553b05 100644 --- a/src/wtf/rtti/type_info.cpp +++ b/src/wtf/rtti/type_info.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include namespace wtf::rtti { @@ -40,4 +56,4 @@ holder_reference TypeInfo::holder_() { return *m_holder_; } const_holder_reference TypeInfo::holder_() const { return *m_holder_; } -} // namespace wtf::rtti \ No newline at end of file +} // namespace wtf::rtti diff --git a/tests/unit_tests/wtf/buffer/buffer_view.cpp b/tests/unit_tests/wtf/buffer/buffer_view.cpp index eb35d50..8b08024 100644 --- a/tests/unit_tests/wtf/buffer/buffer_view.cpp +++ b/tests/unit_tests/wtf/buffer/buffer_view.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -340,4 +356,4 @@ TEMPLATE_LIST_TEST_CASE("contiguous_buffer_cast(BufferView)", "[wtf]", REQUIRE(const_span[1] == two); REQUIRE(const_span[2] == three); REQUIRE(const_span.data() == cdata); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/buffer/detail_/buffer_holder.cpp b/tests/unit_tests/wtf/buffer/detail_/buffer_holder.cpp index 96fe71b..c7e7f4a 100644 --- a/tests/unit_tests/wtf/buffer/detail_/buffer_holder.cpp +++ b/tests/unit_tests/wtf/buffer/detail_/buffer_holder.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include @@ -56,6 +72,11 @@ TEMPLATE_LIST_TEST_CASE("BufferHolder", "[wtf]", default_fp_types) { REQUIRE(empty_holder.type() == wtf::rtti::wtf_typeid()); } + SECTION("is_const()") { + REQUIRE_FALSE(holder.is_const()); + REQUIRE_FALSE(empty_holder.is_const()); + } + SECTION("is_contiguous()") { REQUIRE(holder.is_contiguous()); REQUIRE(empty_holder.is_contiguous()); @@ -80,4 +101,4 @@ TEMPLATE_LIST_TEST_CASE("BufferHolder", "[wtf]", default_fp_types) { std::vector other_vector3{1.0, 2.0, 3.0}; REQUIRE_FALSE(holder.are_equal(other_model_type(other_vector3))); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/buffer/detail_/buffer_view_holder.cpp b/tests/unit_tests/wtf/buffer/detail_/buffer_view_holder.cpp index cec06c8..83e2863 100644 --- a/tests/unit_tests/wtf/buffer/detail_/buffer_view_holder.cpp +++ b/tests/unit_tests/wtf/buffer/detail_/buffer_view_holder.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include @@ -143,4 +159,4 @@ TEMPLATE_LIST_TEST_CASE("BufferViewHolder", "[wtf]", default_fp_types) { const_other_model_type other_const_model(other_vector3.data(), 3); REQUIRE_FALSE(const_holder.are_equal(other_const_model)); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/buffer/detail_/contiguous_model.cpp b/tests/unit_tests/wtf/buffer/detail_/contiguous_model.cpp index f3c9361..9ee08c3 100644 --- a/tests/unit_tests/wtf/buffer/detail_/contiguous_model.cpp +++ b/tests/unit_tests/wtf/buffer/detail_/contiguous_model.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include @@ -55,6 +71,19 @@ TEMPLATE_LIST_TEST_CASE("ContiguousModel", "[wtf]", all_fp_types) { REQUIRE(cmodel.data() == pdata); } + SECTION("span()") { + auto span = model.span(); + REQUIRE(span.data() == pdata); + REQUIRE(span.size() == 3); + } + + SECTION("span() const") { + const auto& cmodel = model; + auto span = cmodel.span(); + REQUIRE(span.data() == pdata); + REQUIRE(span.size() == 3); + } + SECTION("operator==") { REQUIRE(model == model_type(vector_type{one, two, three})); @@ -85,6 +114,8 @@ TEMPLATE_LIST_TEST_CASE("ContiguousModel", "[wtf]", all_fp_types) { SECTION("size_()") { REQUIRE(model.size() == 3); } + SECTION("is_const_()") { REQUIRE_FALSE(model.is_const()); } + SECTION("is_contiguous_()") { REQUIRE(model.is_contiguous()); } SECTION("are_equal_") { @@ -100,4 +131,57 @@ TEMPLATE_LIST_TEST_CASE("ContiguousModel", "[wtf]", all_fp_types) { std::vector other_vector{1.0, 2.0, 3.0}; REQUIRE_FALSE(model.are_equal(other_model_type(other_vector))); } -} \ No newline at end of file +} + +struct CheckVisitContiguousModel { + CheckVisitContiguousModel(float* pdataf, double* pdatad) : + pdataf_corr(pdataf), pdatad_corr(pdatad) {} + + auto operator()(std::span span) const { + REQUIRE(span.data() == pdataf_corr); + REQUIRE(span.size() == 3); + } + + auto operator()(std::span span) const { + REQUIRE(span.data() == pdatad_corr); + REQUIRE(span.size() == 3); + } + + auto operator()(std::span lhs, std::span rhs) const { + REQUIRE(lhs.data() == pdataf_corr); + REQUIRE(lhs.size() == 3); + REQUIRE(rhs.data() == pdatad_corr); + REQUIRE(rhs.size() == 3); + } + + template + auto operator()(std::span lhs, std::span rhs) const { + throw std::runtime_error("Only float, double supported"); + } + + float* pdataf_corr; + double* pdatad_corr; +}; + +TEST_CASE("visit_contiguous_model") { + std::vector valf{1.0, 2.0, 3.0}; + std::vector vald{1.0, 2.0, 3.0}; + auto pdataf = valf.data(); + auto pdatad = vald.data(); + + CheckVisitContiguousModel visitor(pdataf, pdatad); + + ContiguousModel modelf(std::move(valf)); + ContiguousModel modeld(std::move(vald)); + + using type_tuple = std::tuple; + + SECTION("one argument") { + visit_contiguous_model(visitor, modelf); + visit_contiguous_model(visitor, modeld); + } + + SECTION("Two arguments") { + visit_contiguous_model(visitor, modelf, modeld); + } +} diff --git a/tests/unit_tests/wtf/buffer/detail_/contiguous_view_model.cpp b/tests/unit_tests/wtf/buffer/detail_/contiguous_view_model.cpp index 76ed46b..d2ea226 100644 --- a/tests/unit_tests/wtf/buffer/detail_/contiguous_view_model.cpp +++ b/tests/unit_tests/wtf/buffer/detail_/contiguous_view_model.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include @@ -189,4 +205,4 @@ TEMPLATE_LIST_TEST_CASE("ContiguousViewModel", "[wtf]", all_fp_types) { const_other_model_type other_const_model(other_vector.data(), 3); REQUIRE_FALSE(const_model.are_equal(other_const_model)); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/buffer/float_buffer.cpp b/tests/unit_tests/wtf/buffer/float_buffer.cpp index 9edbae9..2c949b5 100644 --- a/tests/unit_tests/wtf/buffer/float_buffer.cpp +++ b/tests/unit_tests/wtf/buffer/float_buffer.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -191,4 +207,57 @@ TEMPLATE_LIST_TEST_CASE("contiguous_buffer_cast", "[wtf]", all_fp_types) { REQUIRE(span[0] == one); REQUIRE(span[1] == two); REQUIRE(span[2] == three); -} \ No newline at end of file +} + +struct CheckVisitContiguousModel { + CheckVisitContiguousModel(float* pdataf, double* pdatad) : + pdataf_corr(pdataf), pdatad_corr(pdatad) {} + + auto operator()(std::span span) const { + REQUIRE(span.data() == pdataf_corr); + REQUIRE(span.size() == 3); + } + + auto operator()(std::span span) const { + REQUIRE(span.data() == pdatad_corr); + REQUIRE(span.size() == 3); + } + + auto operator()(std::span lhs, std::span rhs) const { + REQUIRE(lhs.data() == pdataf_corr); + REQUIRE(lhs.size() == 3); + REQUIRE(rhs.data() == pdatad_corr); + REQUIRE(rhs.size() == 3); + } + + template + auto operator()(std::span lhs, std::span rhs) const { + throw std::runtime_error("Only float, double supported"); + } + + float* pdataf_corr; + double* pdatad_corr; +}; + +TEST_CASE("visit_contiguous_buffer") { + std::vector valf{1.0, 2.0, 3.0}; + std::vector vald{1.0, 2.0, 3.0}; + auto pdataf = valf.data(); + auto pdatad = vald.data(); + + CheckVisitContiguousModel visitor(pdataf, pdatad); + + FloatBuffer modelf(std::move(valf)); + FloatBuffer modeld(std::move(vald)); + + using type_tuple = std::tuple; + + SECTION("one argument") { + visit_contiguous_buffer(visitor, modelf); + visit_contiguous_buffer(visitor, modeld); + } + + SECTION("Two arguments") { + visit_contiguous_buffer(visitor, modelf, modeld); + } +} diff --git a/tests/unit_tests/wtf/concepts/floating_point.cpp b/tests/unit_tests/wtf/concepts/floating_point.cpp index 35d0293..718f783 100644 --- a/tests/unit_tests/wtf/concepts/floating_point.cpp +++ b/tests/unit_tests/wtf/concepts/floating_point.cpp @@ -1,5 +1,22 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include +#include #include using namespace wtf::concepts; @@ -18,6 +35,7 @@ TEMPLATE_LIST_TEST_CASE("UnmodifiedFloatingPoint", "[wtf][concepts]", STATIC_REQUIRE_FALSE(UnmodifiedFloatingPoint); STATIC_REQUIRE_FALSE(UnmodifiedFloatingPoint); STATIC_REQUIRE_FALSE(UnmodifiedFloatingPoint); + STATIC_REQUIRE_FALSE(UnmodifiedFloatingPoint); } TEMPLATE_LIST_TEST_CASE("FloatingPoint", "[wtf][concepts]", @@ -50,4 +68,4 @@ TEMPLATE_LIST_TEST_CASE("ConstFloatingPoint", "[wtf][concepts]", STATIC_REQUIRE(ConstFloatingPoint); STATIC_REQUIRE_FALSE(ConstFloatingPoint); STATIC_REQUIRE_FALSE(ConstFloatingPoint); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/concepts/iterator.cpp b/tests/unit_tests/wtf/concepts/iterator.cpp index dc9b8ce..be9b13f 100644 --- a/tests/unit_tests/wtf/concepts/iterator.cpp +++ b/tests/unit_tests/wtf/concepts/iterator.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -15,4 +31,4 @@ TEMPLATE_LIST_TEST_CASE("FPIterator", "[wtf][concepts]", STATIC_REQUIRE(FPIterator); STATIC_REQUIRE_FALSE(FPIterator); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/concepts/modifiers.cpp b/tests/unit_tests/wtf/concepts/modifiers.cpp index 08c7c53..f9f7df0 100644 --- a/tests/unit_tests/wtf/concepts/modifiers.cpp +++ b/tests/unit_tests/wtf/concepts/modifiers.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -81,4 +97,4 @@ TEMPLATE_LIST_TEST_CASE("Unmodified", "[wtf][concepts]", STATIC_REQUIRE_FALSE(Unmodified); STATIC_REQUIRE_FALSE(Unmodified); STATIC_REQUIRE_FALSE(Unmodified); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/concepts/wtf_float.cpp b/tests/unit_tests/wtf/concepts/wtf_float.cpp index baae36d..840da63 100644 --- a/tests/unit_tests/wtf/concepts/wtf_float.cpp +++ b/tests/unit_tests/wtf/concepts/wtf_float.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -9,4 +25,4 @@ TEST_CASE("WTFFloat concept", "[wtf]") { STATIC_REQUIRE_FALSE(wtf::concepts::WTFFloat); STATIC_REQUIRE_FALSE(wtf::concepts::WTFFloat); STATIC_REQUIRE_FALSE(wtf::concepts::WTFFloat); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/detail_/dispatcher.cpp b/tests/unit_tests/wtf/detail_/dispatcher.cpp index 8b5b1c3..968b2e5 100644 --- a/tests/unit_tests/wtf/detail_/dispatcher.cpp +++ b/tests/unit_tests/wtf/detail_/dispatcher.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include @@ -207,4 +223,4 @@ TEST_CASE("dispatch") { REQUIRE(dispatch(lambda, fm1, fm0) == 42); REQUIRE(dispatch(lambda, fm1, fm1) == 42); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/detail_/downcaster.cpp b/tests/unit_tests/wtf/detail_/downcaster.cpp index 6dbce81..e0d0fb0 100644 --- a/tests/unit_tests/wtf/detail_/downcaster.cpp +++ b/tests/unit_tests/wtf/detail_/downcaster.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include @@ -61,4 +77,4 @@ TEMPLATE_LIST_TEST_CASE("const_downcaster", "", test_wtf::default_fp_types) { auto cr = const_downcaster(cmodel); REQUIRE(cr == const_variant_type{&cmodel}); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/detail_/variant_from_tuple.cpp b/tests/unit_tests/wtf/detail_/variant_from_tuple.cpp index 6b7958c..39f691a 100644 --- a/tests/unit_tests/wtf/detail_/variant_from_tuple.cpp +++ b/tests/unit_tests/wtf/detail_/variant_from_tuple.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -91,4 +107,4 @@ TEST_CASE("ConstVariantFromTuple") { STATIC_REQUIRE(std::is_same_v); STATIC_REQUIRE(std::is_same_v); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/fp/detail_/float_holder.cpp b/tests/unit_tests/wtf/fp/detail_/float_holder.cpp index a7edbe7..6eff9ad 100644 --- a/tests/unit_tests/wtf/fp/detail_/float_holder.cpp +++ b/tests/unit_tests/wtf/fp/detail_/float_holder.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include #include @@ -49,4 +65,4 @@ TEMPLATE_LIST_TEST_CASE("FloatHolder", "[wtf]", all_fp_types) { holder_t& h4 = m4; REQUIRE_FALSE(h.are_equal(h4)); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/fp/detail_/float_model.cpp b/tests/unit_tests/wtf/fp/detail_/float_model.cpp index 608aec0..172d13f 100644 --- a/tests/unit_tests/wtf/fp/detail_/float_model.cpp +++ b/tests/unit_tests/wtf/fp/detail_/float_model.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include #include @@ -100,4 +116,4 @@ TEMPLATE_LIST_TEST_CASE("FloatModel", "[float_model]", test_wtf::all_fp_types) { FloatModel m4(other_type(3.14)); REQUIRE_FALSE(m.are_equal(m4)); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/fp/detail_/float_view_holder.cpp b/tests/unit_tests/wtf/fp/detail_/float_view_holder.cpp index 376d474..660e0a2 100644 --- a/tests/unit_tests/wtf/fp/detail_/float_view_holder.cpp +++ b/tests/unit_tests/wtf/fp/detail_/float_view_holder.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include #include diff --git a/tests/unit_tests/wtf/fp/detail_/float_view_model.cpp b/tests/unit_tests/wtf/fp/detail_/float_view_model.cpp index b0f5b74..524ac8c 100644 --- a/tests/unit_tests/wtf/fp/detail_/float_view_model.cpp +++ b/tests/unit_tests/wtf/fp/detail_/float_view_model.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include #include diff --git a/tests/unit_tests/wtf/fp/float.cpp b/tests/unit_tests/wtf/fp/float.cpp index de30d77..9c36f57 100644 --- a/tests/unit_tests/wtf/fp/float.cpp +++ b/tests/unit_tests/wtf/fp/float.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include @@ -118,4 +134,4 @@ TEST_CASE("float_cast", "[wtf]") { REQUIRE(float_cast(f) == 1.23f); REQUIRE_THROWS_AS(float_cast(f), std::runtime_error); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/fp/float_view.cpp b/tests/unit_tests/wtf/fp/float_view.cpp index 049d9e9..6ec3ef6 100644 --- a/tests/unit_tests/wtf/fp/float_view.cpp +++ b/tests/unit_tests/wtf/fp/float_view.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include diff --git a/tests/unit_tests/wtf/rtti/detail_/type_holder.cpp b/tests/unit_tests/wtf/rtti/detail_/type_holder.cpp index 1ea41a2..492936f 100644 --- a/tests/unit_tests/wtf/rtti/detail_/type_holder.cpp +++ b/tests/unit_tests/wtf/rtti/detail_/type_holder.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include #include diff --git a/tests/unit_tests/wtf/rtti/detail_/type_model.cpp b/tests/unit_tests/wtf/rtti/detail_/type_model.cpp index 795231d..b25acbe 100644 --- a/tests/unit_tests/wtf/rtti/detail_/type_model.cpp +++ b/tests/unit_tests/wtf/rtti/detail_/type_model.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../../test_wtf.hpp" #include #include diff --git a/tests/unit_tests/wtf/rtti/type_info.cpp b/tests/unit_tests/wtf/rtti/type_info.cpp index b6affb1..49b1ccf 100644 --- a/tests/unit_tests/wtf/rtti/type_info.cpp +++ b/tests/unit_tests/wtf/rtti/type_info.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include @@ -139,4 +155,4 @@ TEST_CASE("is_implicitly_convertible") { REQUIRE_FALSE(rtti::is_implicitly_convertible(ctc, ctf)); REQUIRE_FALSE(rtti::is_implicitly_convertible(ctc, ctd)); REQUIRE(rtti::is_implicitly_convertible(ctc, ctc)); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/type_traits/float_traits.cpp b/tests/unit_tests/wtf/type_traits/float_traits.cpp index ff0e2ad..522be37 100644 --- a/tests/unit_tests/wtf/type_traits/float_traits.cpp +++ b/tests/unit_tests/wtf/type_traits/float_traits.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include @@ -42,4 +58,4 @@ TEMPLATE_LIST_TEST_CASE("float_traits", "[type_traits]", } } -#undef UNPACK_TRAITS \ No newline at end of file +#undef UNPACK_TRAITS diff --git a/tests/unit_tests/wtf/type_traits/is_convertible.cpp b/tests/unit_tests/wtf/type_traits/is_convertible.cpp index 95d376c..81259f5 100644 --- a/tests/unit_tests/wtf/type_traits/is_convertible.cpp +++ b/tests/unit_tests/wtf/type_traits/is_convertible.cpp @@ -1,4 +1,21 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" +#include #include #include @@ -22,4 +39,4 @@ TEST_CASE("IsConvertible") { check_conversions({true, true, true}); check_conversions({false, false, false}); REQUIRE(IsConvertible::value); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/type_traits/is_floating_point.cpp b/tests/unit_tests/wtf/type_traits/is_floating_point.cpp index 7c59070..0ea3973 100644 --- a/tests/unit_tests/wtf/type_traits/is_floating_point.cpp +++ b/tests/unit_tests/wtf/type_traits/is_floating_point.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -11,4 +27,4 @@ TEMPLATE_LIST_TEST_CASE("IsFloatingPoint (false)", "[type_traits]", test_wtf::not_fp_types) { STATIC_REQUIRE_FALSE(wtf::type_traits::IsFloatingPoint::value); STATIC_REQUIRE_FALSE(wtf::type_traits::is_floating_point_v); -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/type_traits/precision.cpp b/tests/unit_tests/wtf/type_traits/precision.cpp index 000c63d..235793d 100644 --- a/tests/unit_tests/wtf/type_traits/precision.cpp +++ b/tests/unit_tests/wtf/type_traits/precision.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include @@ -21,4 +37,4 @@ TEST_CASE("Precision") { STATIC_REQUIRE(Precision::value == 0); STATIC_REQUIRE(precision_v == 0); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/type_traits/tupple_append.cpp b/tests/unit_tests/wtf/type_traits/tupple_append.cpp index 004dad2..0627f13 100644 --- a/tests/unit_tests/wtf/type_traits/tupple_append.cpp +++ b/tests/unit_tests/wtf/type_traits/tupple_append.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include @@ -32,4 +48,4 @@ TEST_CASE("TuppleAppend") { using expected21 = std::tuple; REQUIRE(std::is_same_v); } -} \ No newline at end of file +} diff --git a/tests/unit_tests/wtf/type_traits/type_name.cpp b/tests/unit_tests/wtf/type_traits/type_name.cpp index 8e15a61..2211ad6 100644 --- a/tests/unit_tests/wtf/type_traits/type_name.cpp +++ b/tests/unit_tests/wtf/type_traits/type_name.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2025 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "../../../test_wtf.hpp" #include #include @@ -16,4 +32,4 @@ TEST_CASE("TypeName") { std::string custom_corr = "test_wtf::MyCustomFloat"; REQUIRE(TypeName::value == custom_corr); REQUIRE(type_name_v == custom_corr); -} \ No newline at end of file +}