From 300bf973264dd9ecd876582685bfa7471ba83554 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 14:31:25 +0100 Subject: build: set standard dependency on library --- CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba03c5f..c6a645c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,11 +6,6 @@ project("newtype" DESCRIPTION "A library of types and functions to create strong type aliases" ) -set(CMAKE_CXX_STANDARD "20") -set(CMAKE_CXX_STANDARD_REQUIRED YES) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) - include("CTest") include("CMakePackageConfigHelpers") @@ -23,6 +18,10 @@ target_include_directories("${PROJECT_NAME}" INTERFACE $ ) +target_compile_features("${PROJECT_NAME}" INTERFACE + "cxx_std_20" +) + install(TARGETS "${PROJECT_NAME}" EXPORT "${PROJECT_NAME}Targets" PUBLIC_HEADER DESTINATION "include" -- cgit v1.2.3 From 714c18a369e8d974821de0c86598163672533c70 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 14:31:53 +0100 Subject: build: convert test execution to command --- CMakeLists.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6a645c..37a3460 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,10 @@ project("newtype" include("CTest") include("CMakePackageConfigHelpers") +# Project Options + +option(RUN_TESTS_AFTER_BUILD "Automatically run the unit tests after building" ON) + # 'newtype' library add_library("${PROJECT_NAME}" INTERFACE) @@ -78,12 +82,14 @@ if(BUILD_TESTING) discover_tests(TARGET "${PROJECT_NAME}_tests") - add_custom_target("run_all_tests" - COMMAND ${CMAKE_CTEST_COMMAND} "--output-on-failure" - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - DEPENDS "newtype_tests" - COMMENT "Running unit tests" + if(RUN_TESTS_AFTER_BUILD) + add_custom_command(TARGET "${PROJECT_NAME}_tests" + POST_BUILD + COMMAND "${CMAKE_CTEST_COMMAND}" "--output-on-failure" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + COMMENT "Running unit tests" ) + endif() endif() # 'newtype' docs -- cgit v1.2.3 From 03280974d3cd82106ff988b4e6541644f4be6759 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 14:43:33 +0100 Subject: pkg: read package description from CMakeLists --- conanfile.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/conanfile.py b/conanfile.py index 8b3e147..1d14249 100644 --- a/conanfile.py +++ b/conanfile.py @@ -4,11 +4,11 @@ from conans import ConanFile, CMake from conans.tools import load -def get_version(): +def read_project_property(property): try: - content = load("CMakeLists.txt") - version = re.search("project\(\"newtype\"\s*VERSION \"(.*)\"", content).group(1) - return version.strip() + cmake_lists = load("CMakeLists.txt") + value = re.search(r"project\(.*{} \"(.*?)\"".format(property), cmake_lists, re.S).group(1) + return value.strip() except: return None @@ -21,10 +21,10 @@ class NewtypeConan(ConanFile): "revision": "auto", } settings = ("compiler",) - version = get_version() + version = read_project_property("VERSION") license = "BSD-3-Clause" url = "https://github.com/fmorgner/newtype" - description = "A library of types and functions to create strong type aliases" + description = read_project_property("DESCRIPTION") generators = "cmake" build_requires = ( "CUTE/2.2.6@fmorgner/stable", @@ -34,9 +34,13 @@ class NewtypeConan(ConanFile): def _configure_cmake(self): cmake = CMake(self) cmake.definitions["BUILD_TESTING"] = True + cmake.definitions["RUN_TESTS_AFTER_BUILD"] = True cmake.configure() return cmake + def configure(self): + del self.settings.compiler.libcxx + def build(self): cmake = self._configure_cmake() cmake.build() -- cgit v1.2.3 From c693d32a3647166b99565f011bbe7e754495ce64 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 15:08:20 +0100 Subject: pkg: mark package as header-only --- conanfile.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1d14249..000831e 100644 --- a/conanfile.py +++ b/conanfile.py @@ -20,7 +20,7 @@ class NewtypeConan(ConanFile): "url": "https://github.com/fmorgner/newtype.git", "revision": "auto", } - settings = ("compiler",) + settings = None version = read_project_property("VERSION") license = "BSD-3-Clause" url = "https://github.com/fmorgner/newtype" @@ -38,18 +38,13 @@ class NewtypeConan(ConanFile): cmake.configure() return cmake - def configure(self): - del self.settings.compiler.libcxx - def build(self): cmake = self._configure_cmake() cmake.build() - cmake.test() def package(self): cmake = self._configure_cmake() cmake.install() - def package_info(self): - if self.settings.compiler in ["gcc"]: - self.cpp_info.cxxflags.append("-std=c++2a") \ No newline at end of file + def package_id(self): + self.info.header_only() \ No newline at end of file -- cgit v1.2.3 From 074be923a5e3509297db170c66af37de3082c991 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 15:26:54 +0100 Subject: pkg: add package test --- test_package/.gitignore | 1 + test_package/CMakeLists.txt | 10 ++++++++++ test_package/conanfile.py | 17 +++++++++++++++++ test_package/main.cpp | 11 +++++++++++ 4 files changed, 39 insertions(+) create mode 100644 test_package/.gitignore create mode 100644 test_package/CMakeLists.txt create mode 100644 test_package/conanfile.py create mode 100644 test_package/main.cpp diff --git a/test_package/.gitignore b/test_package/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/test_package/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..1aafacf --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION "3.0") + +project("TestPackage" CXX) + +set(CMAKE_CXX_STANDARD "20") + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup() + +add_executable("test_package" "main.cpp") \ No newline at end of file diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..0b12b5f --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake + + +class NewtypeTestConan(ConanFile): + settings = None + requires = "newtype/[~=1.0]@fmorgner/stable" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + os.chdir("bin") + self.run(".%stest_package" % os.sep) \ No newline at end of file diff --git a/test_package/main.cpp b/test_package/main.cpp new file mode 100644 index 0000000..95fe763 --- /dev/null +++ b/test_package/main.cpp @@ -0,0 +1,11 @@ +#include "newtype/new_type.hpp" + +#include + +using Integer = nt::new_type; + +auto main() -> int +{ + auto n = Integer{42}; + std::cout << "n == " << n.decay() << '\n'; +} \ No newline at end of file -- cgit v1.2.3 From 52d5330cbb866f050a8f0736c139586c8a22c387 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 21:19:45 +0100 Subject: new_type: begin Iterable implementation --- CMakeLists.txt | 1 + doc/src/index.rst | 126 ++++++++++++++++++----- include/newtype/derivable.hpp | 7 ++ include/newtype/impl/new_type_iterator_types.hpp | 42 ++++++++ include/newtype/impl/type_traits_extensions.hpp | 72 +++++++++++++ include/newtype/new_type.hpp | 80 +++++++++++++- test/include/iterable_suite.hpp | 11 ++ test/src/driver.cpp | 2 + test/src/iterable_suite.cpp | 61 +++++++++++ 9 files changed, 377 insertions(+), 25 deletions(-) create mode 100644 include/newtype/impl/new_type_iterator_types.hpp create mode 100644 test/include/iterable_suite.hpp create mode 100644 test/src/iterable_suite.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 37a3460..fe85a55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ if(BUILD_TESTING) "${PROJECT_SOURCE_DIR}/test/src/equality_comparison_suite.cpp" "${PROJECT_SOURCE_DIR}/test/src/hash_suite.cpp" "${PROJECT_SOURCE_DIR}/test/src/io_operators_suite.cpp" + "${PROJECT_SOURCE_DIR}/test/src/iterable_suite.cpp" "${PROJECT_SOURCE_DIR}/test/src/new_type_constructor_suite.cpp" "${PROJECT_SOURCE_DIR}/test/src/relational_operators_suite.cpp" ) diff --git a/doc/src/index.rst b/doc/src/index.rst index 49db3b6..e8d50d6 100644 --- a/doc/src/index.rst +++ b/doc/src/index.rst @@ -28,7 +28,7 @@ In it, :cpp:class:`new_type` is used to create thre new strong aliases :literal: .. literalinclude:: ../../examples/src/basic_usage.cpp :language: c++ :linenos: - :name: new-type-usage-basic + :name: new-type-usage-basic :caption: Basic usage of :cpp:class:`new_type` However, using :cpp:class:`new_type` in this fashion seem quite cumbersome. @@ -76,7 +76,7 @@ Class template :cpp:class:`new_type` :tparam BaseType: |BaseTypeDoc| :tparam TagType: |TagTypeDoc| :tparam DerivationClause: |DerivationClauseDoc| - + .. versionadded:: 1.0.0 **Member Type Aliases** @@ -87,6 +87,18 @@ Class template :cpp:class:`new_type` .. cpp:type:: derivation_clause_type = decltype(DerivationClause) + .. cpp:type:: iterator = typename BaseType::iterator + + :enablement: This type alias shall be defined iff. this :cpp:class:`new_type`'s :cpp:type:`base_type` has a member type :cpp:type:`iterator ` and the :cpp:var:`derivation clause ` contains :cpp:var:`Iterable`. + + .. versionadded:: 1.1.0 + + .. cpp:type:: const_iterator = typename BaseType::const_iterator + + :enablement: This type alias shall be defined iff. this :cpp:class:`new_type`'s :cpp:type:`base_type` has a member type :cpp:type:`const_iterator ` and the :cpp:var:`derivation clause ` contains :cpp:var:`Iterable`. + + .. versionadded:: 1.1.0 + **Static Data Members** .. cpp:var:: static derivation_clause_type constexpr derivation_clause = DerivationClause @@ -195,6 +207,30 @@ Class template :cpp:class:`new_type` :enablement: This operator shall be available iff. this :cpp:class:`new_type`'s :cpp:var:`derivation clause ` contains :cpp:var:`Indirection` + **Iterators** + + .. cpp:function:: constexpr iterator begin() + + Get an iterator to the beginning of the object contained by this :cpp:class:`new_type` + + :enablement: This function shall be available iff. + + a) this :cpp:class:`new_type`'s :cpp:var:`derivation clause ` contains :cpp:var:`Iterable` and + b) this :cpp:class:`new_type`'s :cpp:type:`base type ` has a non-static member function :cpp:func:`begin() ` that returns an instance of type :cpp:type:`iterator` + + .. versionadded:: 1.1.0 + + .. cpp:function:: constexpr iterator begin() const + + Get a constant iterator to the beginning of the object contained by this :cpp:class:`new_type` + + :enablement: This function shall be available iff. + + a) this :cpp:class:`new_type`'s :cpp:var:`derivation clause ` contains :cpp:var:`Iterable` and + b) this :cpp:class:`new_type`'s :cpp:type:`base type ` has a non-static member function :cpp:func:`begin() const ` that returns an instance of type :cpp:type:`const_iterator` + + .. versionadded:: 1.1.0 + :literal:`namespace`-level functions and function templates ----------------------------------------------------------- @@ -233,7 +269,7 @@ Equality Comparison Operators :returns: The value returned by the comparison of object contained by :literal:`lhs` with an object of the :cpp:type:`base type `. :throws: Any exception thrown by the comparison of object contained by :literal:`lhs` with an object of the :cpp:type:`base type `. This operator shall be noexcept iff. :cpp:type:`new_type::base_type` is *nothrow equals-comparable*. :enablement: This operator shall be available iff. - + a. :cpp:type:`new_type::base_type` supports comparison using :literal:`==` and b. the :cpp:var:`derivation clause ` contains :cpp:var:`EqBase` @@ -252,7 +288,7 @@ Equality Comparison Operators :returns: The value returned by the comparison of an object of :cpp:type:`base type ` with the object contained by :literal:`rhs`. :throws: Any exception thrown by the comparison of an object of :cpp:type:`base type ` with the object contained by :literal:`rhs`. This operator shall be noexcept iff. :cpp:type:`new_type::base_type` is *nothrow equals-comparable*. :enablement: This operator shall be available iff. - + a. :cpp:type:`new_type::base_type` supports comparison using :literal:`==` and b. the :cpp:var:`derivation clause ` contains :cpp:var:`EqBase` @@ -308,7 +344,7 @@ Equality Comparison Operators :returns: The value returned by the comparison of an object of :cpp:type:`base type ` with the object contained by :literal:`rhs`. :throws: Any exception thrown by the comparison of an object of :cpp:type:`base type ` with the object contained by :literal:`rhs`. This operator shall be noexcept iff. :cpp:type:`new_type::base_type` is *nothrow not-equals-comparable*. :enablement: This operator shall be available iff. - + a. :cpp:type:`new_type::base_type` supports comparison using :literal:`!=` and b. the :cpp:var:`derivation clause ` contains :cpp:var:`EqBase` @@ -464,7 +500,7 @@ Arithmetic Operators :returns: A new instance of :cpp:class:`new_type\` containing the result of applying :literal:`+` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the addition operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow addable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -488,7 +524,7 @@ Arithmetic Operators :returns: A reference to the first argument containing the value modified by applying :literal:`+=` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the addition-assignment operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow add-assignable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -512,7 +548,7 @@ Arithmetic Operators :returns: A new instance of :cpp:class:`new_type\` containing the result of applying :literal:`-` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the subtraction operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow subtractable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -536,7 +572,7 @@ Arithmetic Operators :returns: A reference to the first argument containing the value modified by applying :literal:`-=` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the subtraction-assignment operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow subtract-assignable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -560,7 +596,7 @@ Arithmetic Operators :returns: A new instance of :cpp:class:`new_type\` containing the result of applying :literal:`*` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the multiplication operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow multipliable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -584,7 +620,7 @@ Arithmetic Operators :returns: A reference to the first argument containing the value modified by applying :literal:`*=` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the multiplication-assignment operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow multiply-assignable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -608,7 +644,7 @@ Arithmetic Operators :returns: A new instance of :cpp:class:`new_type\` containing the result of applying :literal:`/` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the division operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow dividable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -631,7 +667,7 @@ Arithmetic Operators :returns: A reference to the first argument containing the value modified by applying :literal:`/=` to the objects contained by :literal:`lhs` and :literal:`rhs`. :throws: Any exception thrown by the division-assignment operator of the objects contained by :literal:`lhs` and :literal:`rhs`. This operator shall be noexcept iff. - + a. :cpp:type:`new_type::base_type` is *nothrow divide-assignable* and b. :cpp:type:`new_type::base_type` is *nothrow copy-constructible* @@ -642,6 +678,45 @@ Arithmetic Operators .. versionadded:: 1.0.0 +Iterators +~~~~~~~~~ + +.. cpp:function:: template \ + constexpr new_type::iterator begin(new_type & obj) + + Get an iterator to the beginning of the object contained by an instance of :cpp:class:`new_type` + + :tparam BaseType: |BaseTypeDoc| + :tparam TagType: |TagTypeDoc| + :tparam DerivationClause: |DerivationClauseDoc| + :param obj: The object to retrieve the iterator from + :returns: An iterator to the begining of the object of contained by :literal:`obj`. + :throws: Any exception + :enablement: This function shall be available iff. + + a) :cpp:var:`derivation clause ` contains :cpp:var:`Iterable` and + b) for the :cpp:class:`new_type`'s :cpp:type:`base type ` exists a namespace-level function :literal:`begin(BaseType &)` that returns an instance of type :cpp:type:`new_type::iterator` + + .. versionadded:: 1.1.0 + +.. cpp:function:: template \ + constexpr new_type::const_iterator begin(new_type const & obj) + + Get a constant iterator to the beginning of the object contained by an instance of :cpp:class:`new_type` + + :tparam BaseType: |BaseTypeDoc| + :tparam TagType: |TagTypeDoc| + :tparam DerivationClause: |DerivationClauseDoc| + :param obj: The object to retrieve the iterator from + :returns: An iterator to the begining of the object of contained by :cpp:var:`obj`. + :throws: Any exception + :enablement: This function shall be available iff. + + a) this :cpp:class:`new_type`'s :cpp:var:`derivation clause ` contains :cpp:var:`Iterable` and + b) for the :cpp:class:`new_type`'s :cpp:type:`base type ` exists a namespace-level function :literal:`begin(BaseType const &)` that returns an instance of type :cpp:type:`new_type::const_iterator` + + .. versionadded:: 1.1.0 + :cpp:class:`std::hash` Support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -660,7 +735,7 @@ Arithmetic Operators :returns: The result of applying :cpp:class:`std::hash` to the object contained by :literal:`value` :throws: Any exception thrown by the call operator of the specialization of :cpp:class`std::hash` for the type of the object contained by :literal:`value`. :enablement: This operator shall be available iff. - + a. :cpp:type:`nt::new_type::base_type` is hashable and b. the :cpp:var:`derivation clause ` contains :cpp:var:`Hash `. @@ -731,15 +806,18 @@ Standard derivation tags .. cpp:var:: auto constexpr Indirection = derivable{} - .. .. cpp:function:: constexpr BaseType operator->() noexcept + This tag enables the derivation of the "member access through pointer" operator :cpp:func:`operator->() ()()>` (both in :literal:`const` and non-:literal:`const` variants). + + .. versionadded:: 1.0.0 - .. **enablement:** This operator shall be available iff. this :cpp:class:`new_type`'s :cpp:var:`derivation_clause` contains :cpp:var:`Indirection` +.. cpp:var:: auto constexpr Iterable = derivable{} - .. .. cpp:function:: constexpr BaseType const * operator->() const noexcept + This tag enables the derivation of the following "standard iterator functions": - This tag enables the derivation of the "member access through pointer" operator :cpp:func:`operator->() ()()>` (both in :literal:`const` and non-:literal:`const` variants). + * :cpp:func:`begin() ` + * :cpp:func:`begin() const ` - .. versionadded:: 1.0.0 + .. versionadded:: 1.1.0 .. cpp:var:: auto constexpr Read = derivable{} @@ -750,7 +828,7 @@ Standard derivation tags .. cpp:var:: auto constexpr Relational = derivable{} This tag enables the derivation of the following relational operators: - + * :cpp:func:`operator\<(new_type const &, new_type const &) constexpr bool operator<(new_type const &, new_type const &)>` * :cpp:func:`operator>(new_type const &, new_type const &) constexpr bool operator>(new_type const &, new_type const &)>` * :cpp:func:`operator\<=(new_type const &, new_type const &) constexpr bool operator<=(new_type const &, new_type const &)>` @@ -774,7 +852,7 @@ Function template :cpp:func:`deriving` .. cpp:function:: template \ constexpr derivation_clause deriving(derivable... features) noexcept - + This function can be used to create a new :cpp:class:`derivation_clause` for use in the definitions of instances of :cpp:class:`new_type`. .. versionadded:: 1.0.0 @@ -811,8 +889,8 @@ Class template :cpp:class:`derivation_clause` Check if this :cpp:class:`derivation clause ` contains the given derivation - :tparam DerivableTag: A tag uniquely identifying a derivation - + :tparam DerivableTag: A tag uniquely identifying a derivation + .. cpp:function:: template \ constexpr bool operator()(derivable, derivable...) const noexcept @@ -845,7 +923,7 @@ Class template :cpp:class:`derivation_clause` .. cpp:function:: template \ constexpr bool operator<(derivation_clause other) const noexcept - + Check if this :cpp:class:`derivation clause ` is a subset of the one represented by :cpp:any:`other`. One :cpp:class:`derivation clause ` is considered to be a subset of another iff. the list of derivations of this instance forms a proper subset of the list of derivations of the other. diff --git a/include/newtype/derivable.hpp b/include/newtype/derivable.hpp index 19c79d9..faa844d 100644 --- a/include/newtype/derivable.hpp +++ b/include/newtype/derivable.hpp @@ -60,6 +60,13 @@ namespace nt */ auto constexpr Indirection = derivable{}; + /** + * @brief A tag to enable derivation of the iterator accessors + * + * @since 1.0.0 + */ + auto constexpr Iterable = derivable{}; + /** * @brief A tag to enable derivation of the stream input operator * diff --git a/include/newtype/impl/new_type_iterator_types.hpp b/include/newtype/impl/new_type_iterator_types.hpp new file mode 100644 index 0000000..037f08d --- /dev/null +++ b/include/newtype/impl/new_type_iterator_types.hpp @@ -0,0 +1,42 @@ +#ifndef NEWTYPE_IMPL_NEW_TYPE_ITERATOR_TYPES_HPP +#define NEWTYPE_IMPL_NEW_TYPE_ITERATOR_TYPES_HPP + +#include "newtype/version.hpp" + +#include + +namespace nt::impl +{ + + template> + struct new_type_iterator + { + }; + + template + struct new_type_iterator> + { + using iterator = typename T::iterator; + }; + + template> + struct new_type_const_iterator + { + }; + + template + struct new_type_const_iterator> + { + using const_iterator = typename T::const_iterator; + }; + + template + struct new_type_iterator_types + : new_type_iterator + , new_type_const_iterator + { + }; + +} // namespace nt::impl + +#endif \ No newline at end of file diff --git a/include/newtype/impl/type_traits_extensions.hpp b/include/newtype/impl/type_traits_extensions.hpp index 1f46fb4..7096578 100644 --- a/include/newtype/impl/type_traits_extensions.hpp +++ b/include/newtype/impl/type_traits_extensions.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace nt::impl @@ -1051,6 +1052,77 @@ namespace nt::impl } // namespace std_support + inline namespace iterable + { + template + struct has_std_begin : std::false_type + { + }; + + template + struct has_std_begin()))>> + : std::is_same()))>> + { + }; + + template + struct has_std_begin()))>> + : std::is_same()))>> + { + }; + + template + auto constexpr has_std_begin_v = has_std_begin::value; + + template + struct has_free_begin : std::false_type + { + }; + + template + struct has_free_begin()))>> + : std::is_same()))>> + { + }; + + template + struct has_free_begin()))>> + : std::is_same()))>> + { + }; + + template + auto constexpr has_free_begin_v = has_free_begin::value; + + template + struct has_member_begin : std::false_type + { + }; + + template + struct has_member_begin().begin())>> + : std::is_same().begin())>> + { + }; + + template + struct has_member_begin().begin())>> + : std::is_same().begin())>> + { + }; + + template + auto constexpr has_member_begin_v = has_member_begin::value; + + template + struct has_begin : std::disjunction, has_free_begin, has_member_begin> + { + }; + + template + auto constexpr has_begin_v = has_begin::value; + } // namespace iterable + } // namespace nt::impl #endif \ No newline at end of file diff --git a/include/newtype/new_type.hpp b/include/newtype/new_type.hpp index ed1de44..0aa1a2e 100644 --- a/include/newtype/new_type.hpp +++ b/include/newtype/new_type.hpp @@ -3,12 +3,14 @@ #include "newtype/derivable.hpp" #include "newtype/deriving.hpp" +#include "newtype/impl/new_type_iterator_types.hpp" #include "newtype/impl/new_type_storage.hpp" #include "newtype/impl/type_traits_extensions.hpp" #include "newtype/version.hpp" #include #include +#include #include #include @@ -26,7 +28,9 @@ namespace nt * @tparam DervivationClause An nt::derivation_clause describing which features shall be automatically derived for the new type alias */ template - class new_type : impl::new_type_move_assignment + class new_type + : impl::new_type_move_assignment + , public impl::new_type_iterator_types { static_assert(!std::is_reference_v, "The base type must not be a reference type"); static_assert(!std::is_void_v>, "The base type must not be possibly cv-qualified void"); @@ -209,6 +213,51 @@ namespace nt { return std::addressof(this->m_value); } + + /// @section Iterators + + /** + * @brief Get the begin iterator of the base type + * + * @return An iterator to the beginning of the base type sequence + * @throw Any exception thrown by the overload of 'begin' selected + */ + template * = nullptr> + auto constexpr begin() + -> std::enable_if_t, typename NewType::iterator> + { + if constexpr (impl::has_member_begin_v) + { + return this->m_value.begin(); + } + else + { + using std::begin; + return begin(this->m_value); + } + } + + /** + * @brief Get the begin iterator of the base type + * + * @note Overload for constant instances + * @return An iterator to the beginning of the base type sequence + * @throw Any exception thrown by the overload of 'begin' selected + */ + template + auto constexpr begin() const + -> std::enable_if_t, typename NewType::const_iterator> + { + if constexpr (impl::has_member_begin_v) + { + return this->m_value.begin(); + } + else + { + using std::begin; + return begin(this->m_value); + } + } }; /// @section Equality comparison operators @@ -569,6 +618,35 @@ namespace nt return lhs; } + /// @section Free Iterator Accessors + + /** + * @brief Get the begin iterator of the base type + * + * @return An iterator to the beginning of the base type sequence + * @throw Any exception thrown by the overload of 'begin' selected + */ + template> + auto constexpr begin(new_type & obj) + -> std::enable_if_t, typename NewType::iterator> + { + return begin(obj); + } + + /** + * @brief Get the begin iterator of the base type + * + * @note Overload for constant instances + * @return An iterator to the beginning of the base type sequence + * @throw Any exception thrown by the overload of 'begin' selected + */ + template> + auto constexpr begin(new_type const & obj) + -> std::enable_if_t, typename NewType::const_iterator> + { + return begin(obj); + } + } // namespace nt namespace std diff --git a/test/include/iterable_suite.hpp b/test/include/iterable_suite.hpp new file mode 100644 index 0000000..c2bbc6e --- /dev/null +++ b/test/include/iterable_suite.hpp @@ -0,0 +1,11 @@ +#ifndef NEWTYPE_TEST_ITERABLE_SUITE_HPP +#define NEWTYPE_TEST_ITERABLE_SUITE_HPP + +#include + +#include +#include + +auto iterable_suite() -> std::pair; + +#endif \ No newline at end of file diff --git a/test/src/driver.cpp b/test/src/driver.cpp index cfd6b90..a0e8904 100644 --- a/test/src/driver.cpp +++ b/test/src/driver.cpp @@ -4,6 +4,7 @@ #include "equality_comparison_suite.hpp" #include "hash_suite.hpp" #include "io_operators_suite.hpp" +#include "iterable_suite.hpp" #include "new_type_constructor_suite.hpp" #include "relational_operators_suite.hpp" @@ -61,6 +62,7 @@ int main(int argc, char ** argv) io_operators_suite(), arithmetic_suite(), hash_suite(), + iterable_suite(), }; auto selectors = get_test_selectors(suites); diff --git a/test/src/iterable_suite.cpp b/test/src/iterable_suite.cpp new file mode 100644 index 0000000..2470571 --- /dev/null +++ b/test/src/iterable_suite.cpp @@ -0,0 +1,61 @@ +#include "iterable_suite.hpp" + +#include "kawaii.hpp" +#include "newtype/derivable.hpp" +#include "newtype/deriving.hpp" +#include "newtype/impl/type_traits_extensions.hpp" +#include "newtype/new_type.hpp" + +#include + +#include +#include + +namespace +{ + +} + +inline namespace begin_tests +{ + + auto a_new__type_not_deriving_iterable_has_no_begin() -> void + { + using type_alias = nt::new_type; + ASSERT(!(nt::impl::has_begin_v)); + } + + auto a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_begin() -> void + { + static_assert(!nt::impl::has_begin_v); + using type_alias = nt::new_type; + ASSERT(!(nt::impl::has_begin_v)); + } + + auto a_new__type_based_on_an_iterable_type_with_member_begin_deriving_iterable_has_member_begin() -> void + { + static_assert(nt::impl::has_member_begin_v>); + using type_alias = nt::new_type, struct tag, deriving(nt::Iterable)>; + ASSERT(nt::impl::has_member_begin_v); + } + + auto a_new__type_based_on_an_iterable_type_with_constant_member_begin_deriving_iterable_has_constant_member_begin() -> void + { + static_assert(nt::impl::has_member_begin_v>); + using type_alias = nt::new_type, struct tag, deriving(nt::Iterable)>; + ASSERT(nt::impl::has_member_begin_v); + } + +} // namespace begin_tests + +auto iterable_suite() -> std::pair +{ + return {{ + /// 'begin' Tests + KAWAII(a_new__type_not_deriving_iterable_has_no_begin), + KAWAII(a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_begin), + KAWAII(a_new__type_based_on_an_iterable_type_with_member_begin_deriving_iterable_has_member_begin), + KAWAII(a_new__type_based_on_an_iterable_type_with_constant_member_begin_deriving_iterable_has_constant_member_begin), + }, + "Iterable Tests"}; +} \ No newline at end of file -- cgit v1.2.3 From aff9ce77fa93c0ecd530e0c39c89ebd0b3fb1ae5 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 21:26:15 +0100 Subject: doc: update python dependencies --- doc/Pipfile.lock | 74 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/doc/Pipfile.lock b/doc/Pipfile.lock index f23f13b..5cf9831 100644 --- a/doc/Pipfile.lock +++ b/doc/Pipfile.lock @@ -25,10 +25,10 @@ }, "babel": { "hashes": [ - "sha256:af92e6106cb7c55286b25b38ad7695f8b4efb36a90ba483d7f7a6628c46158ab", - "sha256:e86135ae101e31e2c8ec20a4e0c5220f4eed12487d5cf3f78be7e98d3a57fc28" + "sha256:1aac2ae2d0d8ea368fa90906567f5c08463d98ade155c0c4bfedd6a0f7160e38", + "sha256:d670ea0b10f8b723672d3a6abeb87b565b244da220d76b4dba1b66269ec152d4" ], - "version": "==2.7.0" + "version": "==2.8.0" }, "certifi": { "hashes": [ @@ -46,32 +46,31 @@ }, "docutils": { "hashes": [ - "sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0", - "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", - "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" + "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af", + "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc" ], - "version": "==0.15.2" + "version": "==0.16" }, "idna": { "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb", + "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa" ], - "version": "==2.8" + "version": "==2.9" }, "imagesize": { "hashes": [ - "sha256:3f349de3eb99145973fefb7dbe38554414e5c30abd0c8e4b970a7c9d09f3a1d8", - "sha256:f3832918bc3c66617f92e35f5d70729187676313caa60c187eb0f28b8fe5e3b5" + "sha256:6965f19a6a2039c7d48bca7dba2473069ff854c36ae6f19d2cde309d998228a1", + "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1" ], - "version": "==1.1.0" + "version": "==1.2.0" }, "jinja2": { "hashes": [ - "sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f", - "sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de" + "sha256:93187ffbc7808079673ef52771baa950426fd664d3aad1d0fa3e95644360e250", + "sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49" ], - "version": "==2.10.3" + "version": "==2.11.1" }, "markupsafe": { "hashes": [ @@ -79,13 +78,16 @@ "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", + "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", + "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b", "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", + "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", @@ -102,16 +104,18 @@ "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" + "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2", + "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7", + "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be" ], "version": "==1.1.1" }, "packaging": { "hashes": [ - "sha256:28b924174df7a2fa32c1953825ff29c61e2f5e082343165438812f00d3a7fc47", - "sha256:d9551545c6d761f3def1677baf08ab2a3ca17c56879e70fecba2fc4dde4ed108" + "sha256:170748228214b70b672c581a3dd610ee51f733018650740e98c7df862a583f73", + "sha256:e665345f9eef0c621aa0bf2f8d78cf6d21904eef16a93f020240b704a57f1334" ], - "version": "==19.2" + "version": "==20.1" }, "pygments": { "hashes": [ @@ -136,17 +140,17 @@ }, "requests": { "hashes": [ - "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", - "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" + "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee", + "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6" ], - "version": "==2.22.0" + "version": "==2.23.0" }, "six": { "hashes": [ - "sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd", - "sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66" + "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", + "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" ], - "version": "==1.13.0" + "version": "==1.14.0" }, "snowballstemmer": { "hashes": [ @@ -157,11 +161,11 @@ }, "sphinx": { "hashes": [ - "sha256:298537cb3234578b2d954ff18c5608468229e116a9757af3b831c2b2b4819159", - "sha256:e6e766b74f85f37a5f3e0773a1e1be8db3fcb799deb58ca6d18b70b0b44542a5" + "sha256:525527074f2e0c2585f68f73c99b4dc257c34bbe308b27f5f8c7a6e20642742f", + "sha256:543d39db5f82d83a5c1aa0c10c88f2b6cff2da3e711aa849b2c627b4b403bbd9" ], "index": "pypi", - "version": "==2.3.1" + "version": "==2.4.2" }, "sphinxcontrib-applehelp": { "hashes": [ @@ -179,10 +183,10 @@ }, "sphinxcontrib-htmlhelp": { "hashes": [ - "sha256:4670f99f8951bd78cd4ad2ab962f798f5618b17675c35c5ac3b2132a14ea8422", - "sha256:d4fd39a65a625c9df86d7fa8a2d9f3cd8299a3a4b15db63b50aac9e161d8eff7" + "sha256:3c0bc24a2c41e340ac37c85ced6dafc879ab485c095b1d65d2461ac2f7cca86f", + "sha256:e8f5bb7e31b2dbb25b9cc435c8ab7a79787ebf7f906155729338f3156d93659b" ], - "version": "==1.0.2" + "version": "==1.0.3" }, "sphinxcontrib-jsmath": { "hashes": [ @@ -207,10 +211,10 @@ }, "urllib3": { "hashes": [ - "sha256:a8a318824cc77d1fd4b2bec2ded92646630d7fe8619497b142c84a9e6f5a7293", - "sha256:f3c5fd51747d450d4dcf6f923c81f78f811aab8205fda64b0aba34a4e48b0745" + "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc", + "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc" ], - "version": "==1.25.7" + "version": "==1.25.8" } }, "develop": {} -- cgit v1.2.3 From e86b0f201c48fc36b1f635a892d3d0ee3d1e3dfe Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 21:40:17 +0100 Subject: doc: try to install deps from Pipfile --- .readthedocs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 6514c09..041d294 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,7 +8,9 @@ formats: python: version: 3.7 + install: + - pipfile: doc sphinx: builder: singlehtml - configuration: doc/src/conf.py \ No newline at end of file + configuration: doc/src/conf.py -- cgit v1.2.3 From 4ae07755ec05877a4ad88e82429b2ea9685b5587 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 21:42:09 +0100 Subject: doc: try to fix rtd configuration --- .readthedocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 041d294..fcbb0ed 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -9,7 +9,8 @@ formats: python: version: 3.7 install: - - pipfile: doc + - method: pipfile + path: doc sphinx: builder: singlehtml -- cgit v1.2.3 From 8f94dedb7bf0eb02af42199ef5ebb26de498b176 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 21:51:50 +0100 Subject: doc: replace Pipfile with requirements.txt --- .readthedocs.yml | 3 +- CMakeLists.txt | 2 +- doc/.gitignore | 2 + doc/Pipfile | 12 --- doc/Pipfile.lock | 221 --------------------------------------------------- doc/requirements.txt | 1 + 6 files changed, 5 insertions(+), 236 deletions(-) create mode 100644 doc/.gitignore delete mode 100644 doc/Pipfile delete mode 100644 doc/Pipfile.lock create mode 100644 doc/requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index fcbb0ed..9f785e6 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -9,8 +9,7 @@ formats: python: version: 3.7 install: - - method: pipfile - path: doc + - requirements: docs/requirements.txt sphinx: builder: singlehtml diff --git a/CMakeLists.txt b/CMakeLists.txt index fe85a55..398b0c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,7 +103,7 @@ if(BUILD_DOCS) message(FATAL_ERROR "Could not find pipenv") endif() - execute_process(COMMAND "${PIPENV_EXE}" "install" + execute_process(COMMAND "${PIPENV_EXE}" "install" "-r" "requirements.txt" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/doc" OUTPUT_QUIET ) diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..ee826c1 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,2 @@ +Pipfile +Pipfile.lock diff --git a/doc/Pipfile b/doc/Pipfile deleted file mode 100644 index 83bd30b..0000000 --- a/doc/Pipfile +++ /dev/null @@ -1,12 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] - -[packages] -sphinx = "*" - -[requires] -python_version = "3" diff --git a/doc/Pipfile.lock b/doc/Pipfile.lock deleted file mode 100644 index 5cf9831..0000000 --- a/doc/Pipfile.lock +++ /dev/null @@ -1,221 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "776b8d64e53c6045ac2d3198bb1516e980e399d054e903e0769d4e6c13350e50" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "alabaster": { - "hashes": [ - "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359", - "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02" - ], - "version": "==0.7.12" - }, - "babel": { - "hashes": [ - "sha256:1aac2ae2d0d8ea368fa90906567f5c08463d98ade155c0c4bfedd6a0f7160e38", - "sha256:d670ea0b10f8b723672d3a6abeb87b565b244da220d76b4dba1b66269ec152d4" - ], - "version": "==2.8.0" - }, - "certifi": { - "hashes": [ - "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3", - "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f" - ], - "version": "==2019.11.28" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "version": "==3.0.4" - }, - "docutils": { - "hashes": [ - "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af", - "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc" - ], - "version": "==0.16" - }, - "idna": { - "hashes": [ - "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb", - "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa" - ], - "version": "==2.9" - }, - "imagesize": { - "hashes": [ - "sha256:6965f19a6a2039c7d48bca7dba2473069ff854c36ae6f19d2cde309d998228a1", - "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1" - ], - "version": "==1.2.0" - }, - "jinja2": { - "hashes": [ - "sha256:93187ffbc7808079673ef52771baa950426fd664d3aad1d0fa3e95644360e250", - "sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49" - ], - "version": "==2.11.1" - }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", - "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", - "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", - "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", - "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", - "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", - "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", - "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", - "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", - "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", - "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", - "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", - "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", - "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", - "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", - "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", - "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7", - "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be" - ], - "version": "==1.1.1" - }, - "packaging": { - "hashes": [ - "sha256:170748228214b70b672c581a3dd610ee51f733018650740e98c7df862a583f73", - "sha256:e665345f9eef0c621aa0bf2f8d78cf6d21904eef16a93f020240b704a57f1334" - ], - "version": "==20.1" - }, - "pygments": { - "hashes": [ - "sha256:2a3fe295e54a20164a9df49c75fa58526d3be48e14aceba6d6b1e8ac0bfd6f1b", - "sha256:98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe" - ], - "version": "==2.5.2" - }, - "pyparsing": { - "hashes": [ - "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f", - "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec" - ], - "version": "==2.4.6" - }, - "pytz": { - "hashes": [ - "sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d", - "sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be" - ], - "version": "==2019.3" - }, - "requests": { - "hashes": [ - "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee", - "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6" - ], - "version": "==2.23.0" - }, - "six": { - "hashes": [ - "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", - "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" - ], - "version": "==1.14.0" - }, - "snowballstemmer": { - "hashes": [ - "sha256:209f257d7533fdb3cb73bdbd24f436239ca3b2fa67d56f6ff88e86be08cc5ef0", - "sha256:df3bac3df4c2c01363f3dd2cfa78cce2840a79b9f1c2d2de9ce8d31683992f52" - ], - "version": "==2.0.0" - }, - "sphinx": { - "hashes": [ - "sha256:525527074f2e0c2585f68f73c99b4dc257c34bbe308b27f5f8c7a6e20642742f", - "sha256:543d39db5f82d83a5c1aa0c10c88f2b6cff2da3e711aa849b2c627b4b403bbd9" - ], - "index": "pypi", - "version": "==2.4.2" - }, - "sphinxcontrib-applehelp": { - "hashes": [ - "sha256:edaa0ab2b2bc74403149cb0209d6775c96de797dfd5b5e2a71981309efab3897", - "sha256:fb8dee85af95e5c30c91f10e7eb3c8967308518e0f7488a2828ef7bc191d0d5d" - ], - "version": "==1.0.1" - }, - "sphinxcontrib-devhelp": { - "hashes": [ - "sha256:6c64b077937330a9128a4da74586e8c2130262f014689b4b89e2d08ee7294a34", - "sha256:9512ecb00a2b0821a146736b39f7aeb90759834b07e81e8cc23a9c70bacb9981" - ], - "version": "==1.0.1" - }, - "sphinxcontrib-htmlhelp": { - "hashes": [ - "sha256:3c0bc24a2c41e340ac37c85ced6dafc879ab485c095b1d65d2461ac2f7cca86f", - "sha256:e8f5bb7e31b2dbb25b9cc435c8ab7a79787ebf7f906155729338f3156d93659b" - ], - "version": "==1.0.3" - }, - "sphinxcontrib-jsmath": { - "hashes": [ - "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", - "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" - ], - "version": "==1.0.1" - }, - "sphinxcontrib-qthelp": { - "hashes": [ - "sha256:513049b93031beb1f57d4daea74068a4feb77aa5630f856fcff2e50de14e9a20", - "sha256:79465ce11ae5694ff165becda529a600c754f4bc459778778c7017374d4d406f" - ], - "version": "==1.0.2" - }, - "sphinxcontrib-serializinghtml": { - "hashes": [ - "sha256:c0efb33f8052c04fd7a26c0a07f1678e8512e0faec19f4aa8f2473a8b81d5227", - "sha256:db6615af393650bf1151a6cd39120c29abaf93cc60db8c48eb2dddbfdc3a9768" - ], - "version": "==1.1.3" - }, - "urllib3": { - "hashes": [ - "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc", - "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc" - ], - "version": "==1.25.8" - } - }, - "develop": {} -} diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000..b80a564 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1 @@ +sphinx==2.4.2 -- cgit v1.2.3 From da08fcb57fd7276649af800a61ee9c008026b6c2 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 21:53:05 +0100 Subject: doc: fix requirements path in rtd config --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 9f785e6..6dd17ed 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -9,7 +9,7 @@ formats: python: version: 3.7 install: - - requirements: docs/requirements.txt + - requirements: doc/requirements.txt sphinx: builder: singlehtml -- cgit v1.2.3 From c4e3450fb1de240ec10eea27e8b9079cab5f8a55 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 22 Feb 2020 17:16:23 +0100 Subject: new_type: adjust enablement of begin --- include/newtype/new_type.hpp | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/include/newtype/new_type.hpp b/include/newtype/new_type.hpp index 0aa1a2e..ef36a75 100644 --- a/include/newtype/new_type.hpp +++ b/include/newtype/new_type.hpp @@ -224,17 +224,9 @@ namespace nt */ template * = nullptr> auto constexpr begin() - -> std::enable_if_t, typename NewType::iterator> + -> std::enable_if_t, typename NewType::iterator> { - if constexpr (impl::has_member_begin_v) - { - return this->m_value.begin(); - } - else - { - using std::begin; - return begin(this->m_value); - } + return this->m_value.begin(); } /** @@ -245,18 +237,10 @@ namespace nt * @throw Any exception thrown by the overload of 'begin' selected */ template - auto constexpr begin() const - -> std::enable_if_t, typename NewType::const_iterator> + auto constexpr begin() const -> std::enable_if_t, + typename NewType::const_iterator> { - if constexpr (impl::has_member_begin_v) - { - return this->m_value.begin(); - } - else - { - using std::begin; - return begin(this->m_value); - } + return this->m_value.begin(); } }; -- cgit v1.2.3 From 85f86c2045135748146606866fc257a2f0e571a0 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 22 Feb 2020 17:19:45 +0100 Subject: doc: add rst linter configuration --- doc8.ini | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 doc8.ini diff --git a/doc8.ini b/doc8.ini new file mode 100644 index 0000000..882336a --- /dev/null +++ b/doc8.ini @@ -0,0 +1,2 @@ +[doc8] +ignore=D001 \ No newline at end of file -- cgit v1.2.3 From dc3d24f193743541cc7e7b623a240fecc2d095f4 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 22 Feb 2020 17:24:31 +0100 Subject: ide: clean up configuration --- .vscode/settings.json | 72 +++++---------------------------------------------- 1 file changed, 6 insertions(+), 66 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8caed1c..d237db4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,75 +1,15 @@ { - "files.associations": { - ".clang-format": "yaml", - "array": "cpp", - "chrono": "cpp", - "functional": "cpp", - "istream": "cpp", - "ostream": "cpp", - "ratio": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "variant