diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2020-03-01 12:19:49 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2020-03-01 12:19:49 +0100 |
| commit | 1bd35044ee96e2bccb66749be5a48307c6e28218 (patch) | |
| tree | a2e1b4760713a20ae63c3a72ae47425a71e7053c | |
| parent | f00fb5779dcf2443b74d114093afbbd2441523ad (diff) | |
| parent | 8c5f53f0c3052cc30c2fe78feb1432b2a5c4e847 (diff) | |
| download | newtype-1bd35044ee96e2bccb66749be5a48307c6e28218.tar.xz newtype-1bd35044ee96e2bccb66749be5a48307c6e28218.zip | |
| -rw-r--r-- | .readthedocs.yml | 4 | ||||
| -rw-r--r-- | .travis.yml | 31 | ||||
| -rw-r--r-- | .vscode/settings.json | 72 | ||||
| -rw-r--r-- | CMakeLists.txt | 119 | ||||
| -rw-r--r-- | LICENSE | 2 | ||||
| -rw-r--r-- | conanfile.py | 21 | ||||
| -rw-r--r-- | doc/.gitignore | 2 | ||||
| -rw-r--r-- | doc/Pipfile | 12 | ||||
| -rw-r--r-- | doc/Pipfile.lock | 217 | ||||
| -rw-r--r-- | doc/requirements.txt | 1 | ||||
| -rw-r--r-- | doc/src/conf.py | 6 | ||||
| -rw-r--r-- | doc/src/index.rst | 440 | ||||
| -rw-r--r-- | doc8.ini | 2 | ||||
| -rw-r--r-- | include/newtype/derivable.hpp | 58 | ||||
| -rw-r--r-- | include/newtype/derivation_clause.hpp | 45 | ||||
| -rw-r--r-- | include/newtype/deriving.hpp | 3 | ||||
| -rw-r--r-- | include/newtype/impl/new_type_iterator_types.hpp | 66 | ||||
| -rw-r--r-- | include/newtype/impl/type_traits_extensions.hpp | 923 | ||||
| -rw-r--r-- | include/newtype/new_type.hpp | 527 | ||||
| -rw-r--r-- | include/newtype/version.hpp | 6 | ||||
| -rw-r--r-- | test/include/iterable_suite.hpp | 11 | ||||
| -rw-r--r-- | test/src/driver.cpp | 2 | ||||
| -rw-r--r-- | test/src/iterable_suite.cpp | 719 | ||||
| -rw-r--r-- | test_package/.gitignore | 1 | ||||
| -rw-r--r-- | test_package/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | test_package/conanfile.py | 17 | ||||
| -rw-r--r-- | test_package/main.cpp | 11 |
27 files changed, 2012 insertions, 1316 deletions
diff --git a/.readthedocs.yml b/.readthedocs.yml index 6514c09..6dd17ed 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,7 +8,9 @@ formats: python: version: 3.7 + install: + - requirements: doc/requirements.txt sphinx: builder: singlehtml - configuration: doc/src/conf.py
\ No newline at end of file + configuration: doc/src/conf.py diff --git a/.travis.yml b/.travis.yml index 5091396..f523e70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,26 +6,37 @@ dist: bionic addons: apt: sources: - - sourceline: "ppa:ubuntu-toolchain-r/test" - packages: ['g++-9'] + - sourceline: 'ppa:ubuntu-toolchain-r/test' + - sourceline: 'deb https://apt.kitware.com/ubuntu/ bionic main' + key_url: 'https://apt.kitware.com/keys/kitware-archive-latest.asc' + packages: + - g++-9 + - cmake + - libperlio-gzip-perl + - libjson-perl compiler: - gcc -env: - - CXX=g++-9 - cache: directories: - $HOME/.conan/data +before_install: + - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 20 + - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 20 + - sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-9 20 + - sudo update-alternatives --config gcc + - sudo update-alternatives --config g++ + - sudo update-alternatives --config gcov + install: - pip install conan - conan user + - git clone git://github.com/linux-test-project/lcov.git + - cd lcov && sudo make install + - cd .. script: - - mkdir -p build - - cd build - - cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON .. - - cmake --build . --target all - - ctest + - /usr/bin/cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=YES -DRUN_TESTS_AFTER_BUILD=YES -DENABLE_CODE_COVERAGE=YES -DPRINT_COVERAGE_REPORT=YES + - /usr/bin/cmake --build build --target all --parallel $(nproc) 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": "cpp", - "atomic": "cpp", - "hash_map": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "cfenv": "cpp", - "cinttypes": "cpp", - "typeinfo": "cpp", - "valarray": "cpp", - "*.ipp": "cpp", - "bitset": "cpp", - "netfwd": "cpp" - }, + // CMake Configuration "cmake.configureArguments": "-DCMAKE_EXPORT_COMPILE_COMMANDS=YES", "cmake.cpptools.intelliSenseMode": "gcc-x64", "cmake.cpptools.guessSourceFileConfigurations": true, + + // C++ Configuration "[cpp]": { "editor.formatOnSave": true }, + "C_Cpp.autoAddFileAssociations": false, + + // RST Configuration "restructuredtext.confPath": "${workspaceFolder}/doc/src" }
\ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ba03c5f..3c29a76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,21 @@ cmake_minimum_required(VERSION "3.9.0") project("newtype" - VERSION "1.0.2" + VERSION "1.1.0" LANGUAGES CXX 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") +# Project Options + +option(RUN_TESTS_AFTER_BUILD "Automatically run the unit tests after building" ON) +option(BUILD_TESTING "Build the unit tests" ON) +option(ENABLE_CODE_COVERAGE "Enable building support for code coverage report generation" ON) +option(PRINT_COVERAGE_REPORT "Print a coverage report after running the unit tests" ON) +option(GENERATE_COVERAGE_REPORT "Generate an HTML coverage report after running the unit tests" OFF) + # 'newtype' library add_library("${PROJECT_NAME}" INTERFACE) @@ -23,6 +25,10 @@ target_include_directories("${PROJECT_NAME}" INTERFACE $<INSTALL_INTERFACE:include> ) +target_compile_features("${PROJECT_NAME}" INTERFACE + "cxx_std_20" +) + install(TARGETS "${PROJECT_NAME}" EXPORT "${PROJECT_NAME}Targets" PUBLIC_HEADER DESTINATION "include" @@ -35,12 +41,31 @@ install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" # 'newtype' tests if(BUILD_TESTING) + enable_testing() + + if(PRINT_COVERAGE_REPORT) + find_program(LCOV_EXE NAMES "lcov") + mark_as_advanced(LCOV_EXE) + if(NOT LCOV_EXE) + message(FATAL_ERROR "lcov is required to generate code coverage reports") + endif() + endif() + + if(GENERATE_COVERAGE_REPORT) + find_program(GENHTML_EXE NAMES "genhtml") + mark_as_advanced(GENHTML_EXE) + if(NOT GENHTML_EXE) + message(FATAL_ERROR "genhtml is required to generate code coverage reports") + endif() + endif() + include("${PROJECT_SOURCE_DIR}/cmake/Modules/DiscoverTests.cmake") include("${PROJECT_SOURCE_DIR}/cmake/Modules/Conan.cmake") conan_check(REQUIRED) conan_add_remote(NAME "fmorgner-public" URL "https://api.bintray.com/conan/fmorgner/conan-public") conan_cmake_run(CONANFILE "conanfile.py" + OUTPUT_QUIET BASIC_SETUP CMAKE_TARGETS BUILD "missing" @@ -56,6 +81,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" ) @@ -75,16 +101,78 @@ if(BUILD_TESTING) "-Wextra" "-Werror" "-pedantic-errors" + $<$<BOOL:${ENABLE_CODE_COVERAGE}>:--coverage> ) - discover_tests(TARGET "${PROJECT_NAME}_tests") + target_link_options("${PROJECT_NAME}_tests" PRIVATE + $<$<BOOL:${ENABLE_CODE_COVERAGE}>:--coverage> + ) - 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" + set_target_properties("${PROJECT_NAME}_tests" PROPERTIES + CXX_EXTENSIONS OFF ) + + discover_tests(TARGET "${PROJECT_NAME}_tests") + + if(RUN_TESTS_AFTER_BUILD) + add_custom_command(TARGET "${PROJECT_NAME}_tests" + POST_BUILD + DEPENDS "${PROJECT_NAME}_tests" + COMMAND "${CMAKE_CTEST_COMMAND}" + ARGS + "--output-on-failure" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + COMMENT "Running unit tests" + ) + endif() + + if(ENABLE_CODE_COVERAGE AND RUN_TESTS_AFTER_BUILD) + add_custom_command(TARGET "${PROJECT_NAME}_tests" + POST_BUILD + BYPRODUCTS "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.coverage.info" + COMMAND "${LCOV_EXE}" + ARGS + "--capture" + "--base-directory" "${PROJECT_SOURCE_DIR}" + "--directory" "${PROJECT_BINARY_DIR}" + "--output-file" "${PROJECT_NAME}.coverage.info" + "--no-external" + "--exclude" "${PROJECT_SOURCE_DIR}/test/\\*" + ">/dev/null" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + COMMENT "Capturing code coverage data" + ) + + if(PRINT_COVERAGE_REPORT) + add_custom_command(TARGET "${PROJECT_NAME}_tests" + POST_BUILD + COMMAND "${LCOV_EXE}" + ARGS + "--list" + "${PROJECT_NAME}.coverage.info" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + COMMENT "Printing code coverage report" + ) + endif() + + if(GENERATE_COVERAGE_REPORT) + add_custom_command(TARGET "${PROJECT_NAME}_tests" + POST_BUILD + BYPRODUCTS "${PROJECT_BINARY_DIR}/coverage-report/index.html" + COMMAND "${GENHTML_EXE}" + ARGS + "--demangle-cpp" + "--highlight" + "--missed" + "--show-details" + "--output" "coverage-report" + "${PROJECT_NAME}.coverage.info" + ">/dev/null" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + COMMENT "Generating code coverage report" + ) + endif() + endif() endif() # 'newtype' docs @@ -93,13 +181,16 @@ option(BUILD_DOCS "Build the library documentation" OFF) if(BUILD_DOCS) find_program(PIPENV_EXE NAMES "pipenv3" "pipenv") + mark_as_advanced(PIPENV_EXE) if(NOT PIPENV_EXE) message(FATAL_ERROR "Could not find pipenv") endif() - execute_process(COMMAND "${PIPENV_EXE}" "install" + message(STATUS "Installing documentation dependencies via pipenv") + execute_process(COMMAND "${PIPENV_EXE}" "install" "-r" "requirements.txt" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/doc" OUTPUT_QUIET + ERROR_QUIET ) set(DOC_SOURCES @@ -1,4 +1,4 @@ -Copyright (c) 2019, Felix Morgner <felix.morgner@gmail.com>, all rights reserved +Copyright (c) 2020, Felix Morgner <felix.morgner@gmail.com>, all rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/conanfile.py b/conanfile.py index 8b3e147..000831e 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 @@ -20,11 +20,11 @@ class NewtypeConan(ConanFile): "url": "https://github.com/fmorgner/newtype.git", "revision": "auto", } - settings = ("compiler",) - version = get_version() + settings = None + 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,18 +34,17 @@ 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 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 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 f23f13b..0000000 --- a/doc/Pipfile.lock +++ /dev/null @@ -1,217 +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:af92e6106cb7c55286b25b38ad7695f8b4efb36a90ba483d7f7a6628c46158ab", - "sha256:e86135ae101e31e2c8ec20a4e0c5220f4eed12487d5cf3f78be7e98d3a57fc28" - ], - "version": "==2.7.0" - }, - "certifi": { - "hashes": [ - "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3", - "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f" - ], - "version": "==2019.11.28" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "version": "==3.0.4" - }, - "docutils": { - "hashes": [ - "sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0", - "sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827", - "sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99" - ], - "version": "==0.15.2" - }, - "idna": { - "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" - ], - "version": "==2.8" - }, - "imagesize": { - "hashes": [ - "sha256:3f349de3eb99145973fefb7dbe38554414e5c30abd0c8e4b970a7c9d09f3a1d8", - "sha256:f3832918bc3c66617f92e35f5d70729187676313caa60c187eb0f28b8fe5e3b5" - ], - "version": "==1.1.0" - }, - "jinja2": { - "hashes": [ - "sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f", - "sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de" - ], - "version": "==2.10.3" - }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "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:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" - ], - "version": "==1.1.1" - }, - "packaging": { - "hashes": [ - "sha256:28b924174df7a2fa32c1953825ff29c61e2f5e082343165438812f00d3a7fc47", - "sha256:d9551545c6d761f3def1677baf08ab2a3ca17c56879e70fecba2fc4dde4ed108" - ], - "version": "==19.2" - }, - "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:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", - "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" - ], - "version": "==2.22.0" - }, - "six": { - "hashes": [ - "sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd", - "sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66" - ], - "version": "==1.13.0" - }, - "snowballstemmer": { - "hashes": [ - "sha256:209f257d7533fdb3cb73bdbd24f436239ca3b2fa67d56f6ff88e86be08cc5ef0", - "sha256:df3bac3df4c2c01363f3dd2cfa78cce2840a79b9f1c2d2de9ce8d31683992f52" - ], - "version": "==2.0.0" - }, - "sphinx": { - "hashes": [ - "sha256:298537cb3234578b2d954ff18c5608468229e116a9757af3b831c2b2b4819159", - "sha256:e6e766b74f85f37a5f3e0773a1e1be8db3fcb799deb58ca6d18b70b0b44542a5" - ], - "index": "pypi", - "version": "==2.3.1" - }, - "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:4670f99f8951bd78cd4ad2ab962f798f5618b17675c35c5ac3b2132a14ea8422", - "sha256:d4fd39a65a625c9df86d7fa8a2d9f3cd8299a3a4b15db63b50aac9e161d8eff7" - ], - "version": "==1.0.2" - }, - "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:a8a318824cc77d1fd4b2bec2ded92646630d7fe8619497b142c84a9e6f5a7293", - "sha256:f3c5fd51747d450d4dcf6f923c81f78f811aab8205fda64b0aba34a4e48b0745" - ], - "version": "==1.25.7" - } - }, - "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 diff --git a/doc/src/conf.py b/doc/src/conf.py index 437d275..1337ce3 100644 --- a/doc/src/conf.py +++ b/doc/src/conf.py @@ -6,10 +6,10 @@ import os # -- Project information ----------------------------------------------------- project = 'newtype' -copyright = '2019, Felix Morgner' +copyright = '2020, Felix Morgner' author = 'Felix Morgner' -version = '1.0' -release = '1.0.0' +version = '1.1' +release = '1.1.0' # -- General configuration --------------------------------------------------- diff --git a/doc/src/index.rst b/doc/src/index.rst index 49db3b6..290f17e 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,30 @@ 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 <new_type::base_type::iterator>` and the :cpp:var:`derivation clause <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 <new_type::base_type::const_iterator>` and the :cpp:var:`derivation clause <derivation_clause>` contains :cpp:var:`Iterable`. + + .. versionadded:: 1.1.0 + + .. cpp:type:: reverse_iterator = typename BaseType::reverse_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:`reverse_iterator <new_type::base_type::reverse_iterator>` and the :cpp:var:`derivation clause <derivation_clause>` contains :cpp:var:`Iterable`. + + .. versionadded:: 1.1.0 + + .. cpp:type:: const_reverse_iterator = typename BaseType::const_reverse_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_reverse_iterator <new_type::base_type::const_reverse_iterator>` and the :cpp:var:`derivation clause <derivation_clause>` contains :cpp:var:`Iterable`. + + .. versionadded:: 1.1.0 + **Static Data Members** .. cpp:var:: static derivation_clause_type constexpr derivation_clause = DerivationClause @@ -168,14 +192,14 @@ Class template :cpp:class:`new_type` .. cpp:function:: constexpr BaseType decay() const - Retrieve the object contained by this :cpp:class:`new_type` object + Retrieve a copy of the object contained by this :cpp:class:`new_type` object :throws: Any exception thrown by the copy-constructor of this :cpp:class:`new_type`'s :cpp:type:`base_type`. This operator shall be noexcept iff. this :cpp:class:`new_type`'s :cpp:type:`base_type` is *nothrow copy-constructible*. .. cpp:function:: constexpr operator BaseType() const - Retrieve the object contained by this :cpp:class:`new_type` object + Retrieve a copy of the object contained by this :cpp:class:`new_type` object :throws: Any exception thrown by the copy-constructor of this :cpp:class:`new_type`'s :cpp:type:`base_type`. This operator shall be noexcept iff. this :cpp:class:`new_type`'s :cpp:type:`base_type` is *nothrow copy-constructible*. @@ -195,6 +219,140 @@ Class template :cpp:class:`new_type` :enablement: This operator shall be available iff. this :cpp:class:`new_type`'s :cpp:var:`derivation clause <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 <derivation_clause>` contains :cpp:var:`Iterable` and + b) this :cpp:class:`new_type`'s :cpp:type:`base type <base_type>` has a non-static member function :cpp:func:`begin() <new_type::base_type::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 <derivation_clause>` contains :cpp:var:`Iterable` and + b) this :cpp:class:`new_type`'s :cpp:type:`base type <base_type>` has a non-static member function :cpp:func:`begin() const <new_type::base_type::begin()>` that returns an instance of type :cpp:type:`const_iterator` + + .. versionadded:: 1.1.0 + + .. cpp:funct |
