Repository: CaseyCarter/cmcstl2 Branch: master Commit: 684a96d527e4 Files: 395 Total size: 1.7 MB Directory structure: gitextract_9l0su0ff/ ├── .cirrus.yml ├── .gitattributes ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── config/ │ ├── ci/ │ │ └── Dockerfile │ └── cmake/ │ └── FindSanitizer.cmake ├── examples/ │ ├── CMakeLists.txt │ └── simple.cpp ├── include/ │ ├── experimental/ │ │ └── ranges/ │ │ ├── algorithm │ │ ├── concepts │ │ ├── functional │ │ ├── iterator │ │ ├── memory │ │ ├── random │ │ ├── range │ │ ├── ranges │ │ ├── type_traits │ │ └── utility │ ├── meta/ │ │ ├── meta.hpp │ │ └── meta_fwd.hpp │ └── stl2/ │ ├── algorithm.hpp │ ├── concepts.hpp │ ├── detail/ │ │ ├── algorithm/ │ │ │ ├── adjacent_find.hpp │ │ │ ├── all_of.hpp │ │ │ ├── any_of.hpp │ │ │ ├── binary_search.hpp │ │ │ ├── copy.hpp │ │ │ ├── copy_backward.hpp │ │ │ ├── copy_if.hpp │ │ │ ├── copy_n.hpp │ │ │ ├── count.hpp │ │ │ ├── count_if.hpp │ │ │ ├── equal.hpp │ │ │ ├── equal_range.hpp │ │ │ ├── fill.hpp │ │ │ ├── fill_n.hpp │ │ │ ├── find.hpp │ │ │ ├── find_end.hpp │ │ │ ├── find_first_of.hpp │ │ │ ├── find_if.hpp │ │ │ ├── find_if_not.hpp │ │ │ ├── for_each.hpp │ │ │ ├── generate.hpp │ │ │ ├── generate_n.hpp │ │ │ ├── heap_sift.hpp │ │ │ ├── includes.hpp │ │ │ ├── inplace_merge.hpp │ │ │ ├── is_heap.hpp │ │ │ ├── is_heap_until.hpp │ │ │ ├── is_partitioned.hpp │ │ │ ├── is_permutation.hpp │ │ │ ├── is_sorted.hpp │ │ │ ├── is_sorted_until.hpp │ │ │ ├── lexicographical_compare.hpp │ │ │ ├── lower_bound.hpp │ │ │ ├── make_heap.hpp │ │ │ ├── max.hpp │ │ │ ├── max_element.hpp │ │ │ ├── merge.hpp │ │ │ ├── min.hpp │ │ │ ├── min_element.hpp │ │ │ ├── minmax.hpp │ │ │ ├── minmax_element.hpp │ │ │ ├── mismatch.hpp │ │ │ ├── move.hpp │ │ │ ├── move_backward.hpp │ │ │ ├── next_permutation.hpp │ │ │ ├── none_of.hpp │ │ │ ├── nth_element.hpp │ │ │ ├── partial_sort.hpp │ │ │ ├── partial_sort_copy.hpp │ │ │ ├── partition.hpp │ │ │ ├── partition_copy.hpp │ │ │ ├── partition_point.hpp │ │ │ ├── pop_heap.hpp │ │ │ ├── prev_permutation.hpp │ │ │ ├── push_heap.hpp │ │ │ ├── remove.hpp │ │ │ ├── remove_copy.hpp │ │ │ ├── remove_copy_if.hpp │ │ │ ├── remove_if.hpp │ │ │ ├── replace.hpp │ │ │ ├── replace_copy.hpp │ │ │ ├── replace_copy_if.hpp │ │ │ ├── replace_if.hpp │ │ │ ├── results.hpp │ │ │ ├── reverse.hpp │ │ │ ├── reverse_copy.hpp │ │ │ ├── rotate.hpp │ │ │ ├── rotate_copy.hpp │ │ │ ├── sample.hpp │ │ │ ├── search.hpp │ │ │ ├── search_n.hpp │ │ │ ├── set_difference.hpp │ │ │ ├── set_intersection.hpp │ │ │ ├── set_symmetric_difference.hpp │ │ │ ├── set_union.hpp │ │ │ ├── shuffle.hpp │ │ │ ├── sort.hpp │ │ │ ├── sort_heap.hpp │ │ │ ├── stable_partition.hpp │ │ │ ├── stable_sort.hpp │ │ │ ├── swap_ranges.hpp │ │ │ ├── transform.hpp │ │ │ ├── unique.hpp │ │ │ ├── unique_copy.hpp │ │ │ └── upper_bound.hpp │ │ ├── cached_position.hpp │ │ ├── cheap_storage.hpp │ │ ├── concepts/ │ │ │ ├── callable.hpp │ │ │ ├── compare.hpp │ │ │ ├── core.hpp │ │ │ ├── function.hpp │ │ │ ├── fundamental.hpp │ │ │ ├── object/ │ │ │ │ ├── assignable.hpp │ │ │ │ ├── movable.hpp │ │ │ │ ├── move_constructible.hpp │ │ │ │ ├── regular.hpp │ │ │ │ └── semiregular.hpp │ │ │ ├── object.hpp │ │ │ └── urng.hpp │ │ ├── construct_destruct.hpp │ │ ├── ebo_box.hpp │ │ ├── functional/ │ │ │ ├── comparisons.hpp │ │ │ ├── invoke.hpp │ │ │ └── not_fn.hpp │ │ ├── fwd.hpp │ │ ├── hash.hpp │ │ ├── iostream/ │ │ │ └── concepts.hpp │ │ ├── iterator/ │ │ │ ├── any_iterator.hpp │ │ │ ├── basic_iterator.hpp │ │ │ ├── common_iterator.hpp │ │ │ ├── concepts.hpp │ │ │ ├── counted_iterator.hpp │ │ │ ├── default_sentinel.hpp │ │ │ ├── increment.hpp │ │ │ ├── insert_iterators.hpp │ │ │ ├── istream_iterator.hpp │ │ │ ├── istreambuf_iterator.hpp │ │ │ ├── move_iterator.hpp │ │ │ ├── operations.hpp │ │ │ ├── ostream_iterator.hpp │ │ │ ├── ostreambuf_iterator.hpp │ │ │ ├── reverse_iterator.hpp │ │ │ └── unreachable.hpp │ │ ├── memory/ │ │ │ ├── concepts.hpp │ │ │ ├── construct_at.hpp │ │ │ ├── destroy.hpp │ │ │ ├── uninitialized_copy.hpp │ │ │ ├── uninitialized_default_construct.hpp │ │ │ ├── uninitialized_fill.hpp │ │ │ ├── uninitialized_move.hpp │ │ │ └── uninitialized_value_construct.hpp │ │ ├── meta.hpp │ │ ├── non_propagating_cache.hpp │ │ ├── randutils.hpp │ │ ├── range/ │ │ │ ├── access.hpp │ │ │ ├── concepts.hpp │ │ │ ├── dangling.hpp │ │ │ ├── nth_iterator.hpp │ │ │ └── primitives.hpp │ │ ├── raw_ptr.hpp │ │ ├── semiregular_box.hpp │ │ ├── span.hpp │ │ ├── swap.hpp │ │ ├── temporary_vector.hpp │ │ ├── tuple_like.hpp │ │ ├── variant.hpp │ │ └── view/ │ │ └── view_closure.hpp │ ├── functional.hpp │ ├── iterator.hpp │ ├── memory.hpp │ ├── random.hpp │ ├── ranges.hpp │ ├── type_traits.hpp │ ├── utility.hpp │ └── view/ │ ├── all.hpp │ ├── common.hpp │ ├── counted.hpp │ ├── drop.hpp │ ├── drop_while.hpp │ ├── empty.hpp │ ├── filter.hpp │ ├── generate.hpp │ ├── indirect.hpp │ ├── iota.hpp │ ├── istream.hpp │ ├── join.hpp │ ├── move.hpp │ ├── ref.hpp │ ├── repeat.hpp │ ├── repeat_n.hpp │ ├── reverse.hpp │ ├── single.hpp │ ├── split.hpp │ ├── subrange.hpp │ ├── take.hpp │ ├── take_exactly.hpp │ ├── take_while.hpp │ ├── transform.hpp │ └── view_interface.hpp └── test/ ├── CMakeLists.txt ├── algorithm/ │ ├── CMakeLists.txt │ ├── adjacent_find.cpp │ ├── all_of.cpp │ ├── any_of.cpp │ ├── binary_search.cpp │ ├── copy.cpp │ ├── copy_backward.cpp │ ├── copy_if.cpp │ ├── copy_n.cpp │ ├── count.cpp │ ├── count_if.cpp │ ├── equal.cpp │ ├── equal_range.cpp │ ├── fill.cpp │ ├── fill_n.cpp │ ├── find.cpp │ ├── find_end.cpp │ ├── find_first_of.cpp │ ├── find_if.cpp │ ├── find_if_not.cpp │ ├── for_each.cpp │ ├── generate.cpp │ ├── generate_n.cpp │ ├── includes.cpp │ ├── inplace_merge.cpp │ ├── is_heap.hpp │ ├── is_heap1.cpp │ ├── is_heap2.cpp │ ├── is_heap3.cpp │ ├── is_heap4.cpp │ ├── is_heap_until.hpp │ ├── is_heap_until1.cpp │ ├── is_heap_until2.cpp │ ├── is_heap_until3.cpp │ ├── is_heap_until4.cpp │ ├── is_partitioned.cpp │ ├── is_permutation.cpp │ ├── is_sorted.cpp │ ├── is_sorted_until.cpp │ ├── lexicographical_compare.cpp │ ├── lower_bound.cpp │ ├── make_heap.cpp │ ├── max.cpp │ ├── max_element.cpp │ ├── merge.cpp │ ├── min.cpp │ ├── min_element.cpp │ ├── minmax.cpp │ ├── minmax_element.cpp │ ├── mismatch.cpp │ ├── move.cpp │ ├── move_backward.cpp │ ├── next_permutation.cpp │ ├── none_of.cpp │ ├── nth_element.cpp │ ├── partial_sort.cpp │ ├── partial_sort_copy.cpp │ ├── partition.cpp │ ├── partition_copy.cpp │ ├── partition_point.cpp │ ├── pop_heap.cpp │ ├── prev_permutation.cpp │ ├── push_heap.cpp │ ├── remove.cpp │ ├── remove_copy.cpp │ ├── remove_copy_if.cpp │ ├── remove_if.cpp │ ├── replace.cpp │ ├── replace_copy.cpp │ ├── replace_copy_if.cpp │ ├── replace_if.cpp │ ├── reverse.cpp │ ├── reverse_copy.cpp │ ├── rotate.cpp │ ├── rotate_copy.cpp │ ├── sample.cpp │ ├── search.cpp │ ├── search_n.cpp │ ├── set_difference.hpp │ ├── set_difference1.cpp │ ├── set_difference2.cpp │ ├── set_difference3.cpp │ ├── set_difference4.cpp │ ├── set_difference5.cpp │ ├── set_difference6.cpp │ ├── set_intersection.hpp │ ├── set_intersection1.cpp │ ├── set_intersection2.cpp │ ├── set_intersection3.cpp │ ├── set_intersection4.cpp │ ├── set_intersection5.cpp │ ├── set_intersection6.cpp │ ├── set_symmetric_difference.hpp │ ├── set_symmetric_difference1.cpp │ ├── set_symmetric_difference2.cpp │ ├── set_symmetric_difference3.cpp │ ├── set_symmetric_difference4.cpp │ ├── set_symmetric_difference5.cpp │ ├── set_symmetric_difference6.cpp │ ├── set_union.hpp │ ├── set_union1.cpp │ ├── set_union2.cpp │ ├── set_union3.cpp │ ├── set_union4.cpp │ ├── set_union5.cpp │ ├── set_union6.cpp │ ├── shuffle.cpp │ ├── sort.cpp │ ├── sort_heap.cpp │ ├── stable_partition.cpp │ ├── stable_sort.cpp │ ├── swap_ranges.cpp │ ├── transform.cpp │ ├── unique.cpp │ ├── unique_copy.cpp │ └── upper_bound.cpp ├── all_public_headers.hpp ├── common-libcxx.hpp ├── common-libstdcxx.hpp ├── common.cpp ├── concepts/ │ ├── CMakeLists.txt │ ├── compare.cpp │ ├── core.cpp │ ├── fundamental.cpp │ ├── iterator.cpp │ ├── object.cpp │ ├── range.cpp │ └── swap.cpp ├── detail/ │ ├── CMakeLists.txt │ ├── raw_ptr.cpp │ └── temporary_vector.cpp ├── functional/ │ ├── CMakeLists.txt │ ├── invoke.cpp │ └── not_fn.cpp ├── headers1.cpp ├── headers2.cpp ├── iterator/ │ ├── CMakeLists.txt │ ├── any_iterator.cpp │ ├── basic_iterator.cpp │ ├── common_iterator.cpp │ ├── counted_iterator.cpp │ ├── incomplete.cpp │ ├── istream_iterator.cpp │ ├── istreambuf_iterator.cpp │ ├── iterator.cpp │ ├── make_range.cpp │ ├── move_iterator.cpp │ ├── operations.cpp │ ├── ostream_iterator.cpp │ ├── ostreambuf_iterator.cpp │ ├── reverse_iterator.cpp │ └── unreachable.cpp ├── memory/ │ ├── CMakeLists.txt │ ├── common.hpp │ ├── destroy.cpp │ ├── uninitialized_copy.cpp │ ├── uninitialized_default_construct.cpp │ ├── uninitialized_fill.cpp │ ├── uninitialized_move.cpp │ └── uninitialized_value_construct.cpp ├── meta.cpp ├── move_only_string.hpp ├── range_access.cpp ├── simple_test.hpp ├── test_iterators.hpp ├── test_utils.hpp └── view/ ├── CMakeLists.txt ├── common_view.cpp ├── counted_view.cpp ├── drop_view.cpp ├── drop_while_view.cpp ├── empty_view.cpp ├── filter_view.cpp ├── generate_view.cpp ├── indirect_view.cpp ├── istream_view.cpp ├── join_view.cpp ├── move_view.cpp ├── ref_view.cpp ├── repeat_n_view.cpp ├── repeat_view.cpp ├── reverse_view.cpp ├── single_view.cpp ├── span.cpp ├── split_view.cpp ├── subrange.cpp ├── take_exactly_view.cpp ├── take_view.cpp ├── take_while_view.cpp └── transform_view.cpp ================================================ FILE CONTENTS ================================================ ================================================ FILE: .cirrus.yml ================================================ # # Copyright Christopher Di Bella # # 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. # task: env: matrix: COMPILER_VERSION: 8 matrix: BUILD_TYPE: Debug BUILD_TYPE: Release container: dockerfile: config/ci/Dockerfile cpu: 8 memory: 16G configure_script: - mkdir -p build - cd build - export CC=`which gcc-${COMPILER_VERSION}` - export CXX=`which g++-${COMPILER_VERSION}` - cmake .. -GNinja -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" build_script: - cd build - ninja -v test_script: - cd build - ctest -j8 --output-on-failure ================================================ FILE: .gitattributes ================================================ # Disable CRLF-mapping for all files. * -text ================================================ FILE: .gitignore ================================================ *.user *~ *.o *.obj a.out \#*# .#* build*/ .vscode/ .vs/ *.*.swp ================================================ FILE: .travis.yml ================================================ # Copyright Casey Carter 2015-2017 # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt) dist: xenial language: cpp cache: directories: - ${TRAVIS_BUILD_DIR}/deps/cmake-3.12.4 matrix: include: - env: GCC_VERSION=8 BUILD_TYPE=Debug os: linux addons: &gcc8 apt: packages: - g++-8 - ninja-build sources: - ubuntu-toolchain-r-test - env: GCC_VERSION=8 BUILD_TYPE=Release os: linux addons: *gcc8 before_install: - if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi - which $CC - which $CXX - $CXX --version - ninja --version - JOBS=2 install: - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - mkdir -p "${DEPS_DIR}" && cd "${DEPS_DIR}" ############################################################################ # Install a recent CMake (unless already installed on OS X) ############################################################################ - | if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then CMAKE_VERSION=3.12.4 if [[ -z "$(ls -A ${DEPS_DIR}/cmake-${CMAKE_VERSION}/bin)" ]]; then CMAKE_URL="https://cmake.org/files/v3.12/cmake-3.12.4-Linux-x86_64.tar.gz" mkdir -p "cmake-${CMAKE_VERSION}" && travis_retry wget --no-check-certificate --quiet -O - "${CMAKE_URL}" | tar --strip-components=1 -xz -C "cmake-${CMAKE_VERSION}" fi export PATH="${DEPS_DIR}/cmake-${CMAKE_VERSION}/bin:${PATH}" fi before_script: - cd "${TRAVIS_BUILD_DIR}" - mkdir -p build - cd build - cmake .. -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" - ninja -v script: - ctest -j${JOBS} --output-on-failure ================================================ FILE: CMakeLists.txt ================================================ # cmcstl2 - A concept-enabled C++ standard library # # Copyright Eric Niebler 2015 # Copyright Casey Carter 2015, 2017 # # Use, modification and distribution is subject to the # Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Project home: https://github.com/caseycarter/cmcstl2 # cmake_minimum_required(VERSION 3.12) project(cmcstl2 CXX) set(CMAKE_CXX_EXTENSIONS OFF) # check if cmcstl2 is not a subproject if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR) option(STL2_BUILD_EXAMPLES "Build stl2 examples" ON) option(STL2_BUILD_TESTING "Build stl2 tests" ON) else() option(STL2_BUILD_EXAMPLES "Build stl2 examples" OFF) option(STL2_BUILD_TESTING "Build stl2 tests" OFF) endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/config/cmake") find_package(Sanitizer COMPONENTS address undefined) add_library(stl2 INTERFACE) target_include_directories(stl2 INTERFACE $ $/include>) target_compile_features(stl2 INTERFACE cxx_std_20) target_compile_options(stl2 INTERFACE $<$:-fconcepts> $<$:-Xclang -fconcepts-ts> $<$:/permissive->) install(DIRECTORY include/ DESTINATION include) install(TARGETS stl2 EXPORT cmcstl2-targets) install(EXPORT cmcstl2-targets DESTINATION lib/cmake/cmcstl2) file( WRITE ${PROJECT_BINARY_DIR}/cmcstl2-config.cmake "include(\${CMAKE_CURRENT_LIST_DIR}/cmcstl2-targets.cmake)") install( FILES ${PROJECT_BINARY_DIR}/cmcstl2-config.cmake DESTINATION lib/cmake/cmcstl2) if(STL2_BUILD_EXAMPLES) add_subdirectory(examples) endif() if(STL2_BUILD_TESTING) include(CTest) add_custom_target(stl2-check ${CMAKE_CTEST_COMMAND} -V) add_subdirectory(test) endif() ================================================ FILE: LICENSE.txt ================================================ ======================================================== Boost Software License - Version 1.0 - August 17th, 2003 ======================================================== Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================================================================== libc++ License ============================================================================== The libc++ library is dual licensed under both the University of Illinois "BSD-Like" license and the MIT license. As a user of this code you may choose to use it under either license. As a contributor, you agree to allow your code to be used under both. Full text of the relevant licenses is included below. ============================================================================== University of Illinois/NCSA Open Source License Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT http://llvm.org/svn/llvm-project/libcxx/trunk/CREDITS.TXT All rights reserved. Developed by: LLVM Team University of Illinois at Urbana-Champaign http://llvm.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. * Neither the names of the LLVM Team, University of Illinois at Urbana-Champaign, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. ============================================================================== Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT http://llvm.org/svn/llvm-project/libcxx/trunk/CREDITS.TXT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================================================================== SGI C++ Standard Template Library license ============================================================================== // Copyright (c) 1994 // Hewlett-Packard Company // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and // that both that copyright notice and this permission notice appear // in supporting documentation. Hewlett-Packard Company makes no // representations about the suitability of this software for any // purpose. It is provided "as is" without express or implied warranty. // // Copyright (c) 1996 // Silicon Graphics Computer Systems, Inc. // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and // that both that copyright notice and this permission notice appear // in supporting documentation. Silicon Graphics makes no // representations about the suitability of this software for any // purpose. It is provided "as is" without express or implied warranty. // ================================================ FILE: README.md ================================================ # cmcstl2 An implementation of [P0896R4 "The One Ranges Proposal"](https://wg21.link/p0896r4). Compilation requires a compiler with support for C++17 and the Concepts TS, which as of this writing means [GCC 7+](https://gcc.gnu.org/) with the `-std=c++1z` and `-fconcepts` command line options. ================================================ FILE: config/ci/Dockerfile ================================================ # cmcstl2 - A concept-enabled C++ standard library # # Copyright Casey Carter # # Use, modification and distribution is subject to the # Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Project home: https://github.com/caseycarter/cmcstl2 # FROM ubuntu:disco # Install packages RUN apt update RUN apt upgrade -y RUN apt update RUN apt install -y git cmake ninja-build g++-8 g++-9 ================================================ FILE: config/cmake/FindSanitizer.cmake ================================================ # # Copyright Christopher Di Bella # Copyright Morris Hafner # # 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(FindPackageHandleStandardArgs) include(CheckCXXCompilerFlag) include(CMakePushCheckState) add_library(Sanitizer::all INTERFACE IMPORTED) set(Sanitizer_FOUND ON) foreach(san ${Sanitizer_FIND_COMPONENTS}) if(TARGET Sanitizer::${san}) continue() endif() cmake_push_check_state(RESET) list(APPEND CMAKE_REQUIRED_LIBRARIES -fsanitize=${san}) check_cxx_compiler_flag(-fsanitize=${san} ${san}_sanitizer_supported) cmake_pop_check_state() if(${${san}_sanitizer_supported}) add_library(Sanitizer::${san} INTERFACE IMPORTED) set_target_properties(Sanitizer::${san} PROPERTIES INTERFACE_COMPILE_OPTIONS -fsanitize=${san} INTERFACE_LINK_LIBRARIES -fsanitize=${san}) set(Sanitizer_${san}_FOUND TRUE) set_property(TARGET Sanitizer::all APPEND PROPERTY INTERFACE_LINK_LIBRARIES Sanitizer::${san}) endif() endforeach() find_package_handle_standard_args(Sanitizer REQUIRED_VARS Sanitizer_FOUND HANDLE_COMPONENTS) ================================================ FILE: examples/CMakeLists.txt ================================================ # cmcstl2 - A concept-enabled C++ standard library # # Copyright Casey Carter 2015, 2017 # # Use, modification and distribution is subject to the # Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Project home: https://github.com/caseycarter/cmcstl2 # add_executable(simple simple.cpp) target_link_libraries(simple stl2) ================================================ FILE: examples/simple.cpp ================================================ #include #include #include #include #include #include // Qualify everything with "std::experimental::ranges" if you like, // I prefer to use a namespace alias: namespace ranges = std::experimental::ranges; template class show_type; template void foo(T&) {} int main() { auto v = std::vector{"this", "is", "a", "test"}; ranges::sort(v); auto out = ranges::ostream_iterator{std::cout, " "}; ranges::copy(v, out); std::cout << '\n'; auto result = ranges::reverse_copy(v, out); std::cout << '\n'; return !(result.in == ranges::end(v)); } ================================================ FILE: include/experimental/ranges/algorithm ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2015 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/concepts ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2015 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/functional ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2015 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/iterator ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2015 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/memory ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2016 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/random ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2015 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/range ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2018 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/ranges ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2018 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/type_traits ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2015 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/experimental/ranges/utility ================================================ // cmcstl2 - A concept-enabled C++ standard library // // Copyright Casey Carter 2015 // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/caseycarter/cmcstl2 // #include ================================================ FILE: include/meta/meta.hpp ================================================ /// \file meta.hpp Tiny meta-programming library. // // Meta library // // Copyright Eric Niebler 2014-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/meta // #ifndef META_HPP #define META_HPP #include #include #include #include #include #ifdef __clang__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wdocumentation-deprecated-sync" #pragma GCC diagnostic ignored "-Wmissing-variable-declarations" #endif /// \defgroup meta Meta /// /// A tiny metaprogramming library /// \defgroup trait Trait /// Trait invocation/composition. /// \ingroup meta /// \defgroup invocation Invocation /// Trait invocation /// \ingroup trait /// \defgroup composition Composition /// Trait composition /// \ingroup trait /// \defgroup logical Logical /// Logical operations /// \ingroup meta /// \defgroup algorithm Algorithms /// Algorithms. /// \ingroup meta /// \defgroup query Query/Search /// Query and search algorithms /// \ingroup algorithm /// \defgroup transformation Transformation /// Transformation algorithms /// \ingroup algorithm /// \defgroup runtime Runtime /// Runtime algorithms /// \ingroup algorithm /// \defgroup datatype Datatype /// Datatypes. /// \ingroup meta /// \defgroup list List /// \ingroup datatype /// \defgroup integral Integer sequence /// Equivalent to C++14's `std::integer_sequence` /// \ingroup datatype /// \defgroup extension Extension /// Extend meta with your own datatypes. /// \ingroup datatype /// \defgroup math Math /// Integral constant arithmetic. /// \ingroup meta /// \defgroup lazy_trait lazy /// \ingroup trait /// \defgroup lazy_invocation lazy /// \ingroup invocation /// \defgroup lazy_composition lazy /// \ingroup composition /// \defgroup lazy_logical lazy /// \ingroup logical /// \defgroup lazy_query lazy /// \ingroup query /// \defgroup lazy_transformation lazy /// \ingroup transformation /// \defgroup lazy_list lazy /// \ingroup list /// \defgroup lazy_datatype lazy /// \ingroup datatype /// \defgroup lazy_math lazy /// \ingroup math /// Tiny metaprogramming library namespace meta { namespace detail { /// Returns a \p T nullptr template constexpr T *_nullptr_v() { return nullptr; } #if META_CXX_VARIABLE_TEMPLATES template META_INLINE_VAR constexpr T *nullptr_v = nullptr; #endif } // namespace detail /// An empty type. /// \ingroup datatype struct nil_ { }; /// Type alias for \p T::type. /// \ingroup invocation template using _t = typename T::type; #if META_CXX_VARIABLE_TEMPLATES || defined(META_DOXYGEN_INVOKED) /// Variable alias for \c T::type::value /// \note Requires C++14 or greater. /// \ingroup invocation template constexpr typename T::type::value_type _v = T::type::value; #endif /// Lazy versions of meta actions namespace lazy { /// \sa `meta::_t` /// \ingroup lazy_invocation template using _t = defer<_t, T>; } // namespace lazy /// An integral constant wrapper for \c std::size_t. /// \ingroup integral template using size_t = std::integral_constant; /// An integral constant wrapper for \c bool. /// \ingroup integral template using bool_ = std::integral_constant; /// An integral constant wrapper for \c int. /// \ingroup integral template using int_ = std::integral_constant; /// An integral constant wrapper for \c char. /// \ingroup integral template using char_ = std::integral_constant; /////////////////////////////////////////////////////////////////////////////////////////// // Math operations /// An integral constant wrapper around the result of incrementing the wrapped integer \c /// T::type::value. template using inc = std::integral_constant; /// An integral constant wrapper around the result of decrementing the wrapped integer \c /// T::type::value. template using dec = std::integral_constant; /// An integral constant wrapper around the result of adding the two wrapped integers /// \c T::type::value and \c U::type::value. /// \ingroup math template using plus = std::integral_constant; /// An integral constant wrapper around the result of subtracting the two wrapped integers /// \c T::type::value and \c U::type::value. /// \ingroup math template using minus = std::integral_constant; /// An integral constant wrapper around the result of multiplying the two wrapped integers /// \c T::type::value and \c U::type::value. /// \ingroup math template using multiplies = std::integral_constant; /// An integral constant wrapper around the result of dividing the two wrapped integers \c /// T::type::value and \c U::type::value. /// \ingroup math template using divides = std::integral_constant; /// An integral constant wrapper around the result of negating the wrapped integer /// \c T::type::value. /// \ingroup math template using negate = std::integral_constant; /// An integral constant wrapper around the remainder of dividing the two wrapped integers /// \c T::type::value and \c U::type::value. /// \ingroup math template using modulus = std::integral_constant; /// A Boolean integral constant wrapper around the result of comparing \c T::type::value and /// \c U::type::value for equality. /// \ingroup math template using equal_to = bool_; /// A Boolean integral constant wrapper around the result of comparing \c T::type::value and /// \c U::type::value for inequality. /// \ingroup math template using not_equal_to = bool_; /// A Boolean integral constant wrapper around \c true if \c T::type::value is greater than /// \c U::type::value; \c false, otherwise. /// \ingroup math template using greater = bool_<(T::type::value > U::type::value)>; /// A Boolean integral constant wrapper around \c true if \c T::type::value is less than \c /// U::type::value; \c false, otherwise. /// \ingroup math template using less = bool_<(T::type::value < U::type::value)>; /// A Boolean integral constant wrapper around \c true if \c T::type::value is greater than /// or equal to \c U::type::value; \c false, otherwise. /// \ingroup math template using greater_equal = bool_<(T::type::value >= U::type::value)>; /// A Boolean integral constant wrapper around \c true if \c T::type::value is less than or /// equal to \c U::type::value; \c false, otherwise. /// \ingroup math template using less_equal = bool_<(T::type::value <= U::type::value)>; /// An integral constant wrapper around the result of bitwise-and'ing the two wrapped /// integers \c T::type::value and \c U::type::value. /// \ingroup math template using bit_and = std::integral_constant; /// An integral constant wrapper around the result of bitwise-or'ing the two wrapped /// integers \c T::type::value and \c U::type::value. /// \ingroup math template using bit_or = std::integral_constant; /// An integral constant wrapper around the result of bitwise-exclusive-or'ing the two /// wrapped integers \c T::type::value and \c U::type::value. /// \ingroup math template using bit_xor = std::integral_constant; /// An integral constant wrapper around the result of bitwise-complementing the wrapped /// integer \c T::type::value. /// \ingroup math template using bit_not = std::integral_constant; namespace lazy { /// \sa 'meta::int' /// \ingroup lazy_math template using inc = defer; /// \sa 'meta::dec' /// \ingroup lazy_math template using dec = defer; /// \sa 'meta::plus' /// \ingroup lazy_math template using plus = defer; /// \sa 'meta::minus' /// \ingroup lazy_math template using minus = defer; /// \sa 'meta::multiplies' /// \ingroup lazy_math template using multiplies = defer; /// \sa 'meta::divides' /// \ingroup lazy_math template using divides = defer; /// \sa 'meta::negate' /// \ingroup lazy_math template using negate = defer; /// \sa 'meta::modulus' /// \ingroup lazy_math template using modulus = defer; /// \sa 'meta::equal_to' /// \ingroup lazy_math template using equal_to = defer; /// \sa 'meta::not_equal_t' /// \ingroup lazy_math template using not_equal_to = defer; /// \sa 'meta::greater' /// \ingroup lazy_math template using greater = defer; /// \sa 'meta::less' /// \ingroup lazy_math template using less = defer; /// \sa 'meta::greater_equal' /// \ingroup lazy_math template using greater_equal = defer; /// \sa 'meta::less_equal' /// \ingroup lazy_math template using less_equal = defer; /// \sa 'meta::bit_and' /// \ingroup lazy_math template using bit_and = defer; /// \sa 'meta::bit_or' /// \ingroup lazy_math template using bit_or = defer; /// \sa 'meta::bit_xor' /// \ingroup lazy_math template using bit_xor = defer; /// \sa 'meta::bit_not' /// \ingroup lazy_math template using bit_not = defer; } // namespace lazy /// \cond namespace detail { enum class indices_strategy_ { done, repeat, recurse }; constexpr indices_strategy_ strategy_(std::size_t cur, std::size_t end) { return cur >= end ? indices_strategy_::done : cur * 2 <= end ? indices_strategy_::repeat : indices_strategy_::recurse; } template constexpr std::size_t range_distance_(T begin, T end) { return begin <= end ? static_cast(end - begin) : throw "The start of the integer_sequence must not be " "greater than the end"; } template struct make_indices_ { using type = State; }; template struct coerce_indices_ { }; } // namespace detail /// \endcond /////////////////////////////////////////////////////////////////////////////////////////// // integer_sequence #if !META_CXX_INTEGER_SEQUENCE /// A container for a sequence of compile-time integer constants. /// \ingroup integral template struct integer_sequence { using value_type = T; /// \return `sizeof...(Is)` static constexpr std::size_t size() noexcept { return sizeof...(Is); } }; #endif /////////////////////////////////////////////////////////////////////////////////////////// // index_sequence /// A container for a sequence of compile-time integer constants of type /// \c std::size_t /// \ingroup integral template using index_sequence = integer_sequence; #if META_HAS_MAKE_INTEGER_SEQ && !defined(META_DOXYGEN_INVOKED) // Implement make_integer_sequence and make_index_sequence with the // __make_integer_seq builtin on compilers that provide it. (Redirect // through decltype to workaround suspected clang bug.) /// \cond namespace detail { template __make_integer_seq make_integer_sequence_(); } /// \endcond template using make_integer_sequence = decltype(detail::make_integer_sequence_()); template using make_index_sequence = make_integer_sequence; #elif META_HAS_INTEGER_PACK && !defined(META_DOXYGEN_INVOKED) // Implement make_integer_sequence and make_index_sequence with the // __integer_pack builtin on compilers that provide it. template using make_integer_sequence = integer_sequence; template using make_index_sequence = make_integer_sequence; #else /// Generate \c index_sequence containing integer constants [0,1,2,...,N-1]. /// \par Complexity /// \f$ O(log(N)) \f$. /// \ingroup integral template using make_index_sequence = _t, detail::strategy_(1, N)>>; /// Generate \c integer_sequence containing integer constants [0,1,2,...,N-1]. /// \par Complexity /// \f$ O(log(N)) \f$. /// \ingroup integral template using make_integer_sequence = _t(N)>>>; #endif /////////////////////////////////////////////////////////////////////////////////////////// // integer_range /// Makes the integer sequence [From, To). /// \par Complexity /// \f$ O(log(To - From)) \f$. /// \ingroup integral template using integer_range = _t>>; /// \cond namespace detail { template struct concat_indices_ { }; template struct concat_indices_, index_sequence> { using type = index_sequence; }; template <> struct make_indices_<0u, index_sequence<0>, indices_strategy_::done> { using type = index_sequence<>; }; template struct make_indices_, indices_strategy_::repeat> : make_indices_, detail::strategy_(sizeof...(Values) * 2, End)> { }; template struct make_indices_, indices_strategy_::recurse> : concat_indices_, make_index_sequence> { }; template struct coerce_indices_> { using type = integer_sequence(static_cast(Values) + Offset)...>; }; } // namespace detail /// \endcond /// Evaluate the Invocable \p Fn with the arguments \p Args. /// \ingroup invocation template using invoke = typename Fn::template invoke; /// Lazy versions of meta actions namespace lazy { /// \sa `meta::invoke` /// \ingroup lazy_invocation template using invoke = defer; } // namespace lazy /// A Trait that always returns its argument \p T. It is also an Invocable /// that always returns \p T. /// \ingroup trait /// \ingroup invocation template struct id { #if defined(META_WORKAROUND_CWG_1558) && !defined(META_DOXYGEN_INVOKED) // Redirect through decltype for compilers that have not // yet implemented CWG 1558: static id impl(void *); template using invoke = _t *>(nullptr)))>; #else template using invoke = T; #endif using type = T; }; /// An alias for type \p T. Useful in non-deduced contexts. /// \ingroup trait template using id_t = _t>; namespace lazy { /// \sa `meta::id` /// \ingroup lazy_trait /// \ingroup lazy_invocation template using id = defer; } // namespace lazy /// An alias for `void`. /// \ingroup trait #if defined(META_WORKAROUND_CWG_1558) && !defined(META_DOXYGEN_INVOKED) // Redirect through decltype for compilers that have not // yet implemented CWG 1558: template using void_ = invoke, Ts...>; #else template using void_ = void; #endif #if META_CXX_VARIABLE_TEMPLATES #ifdef META_CONCEPT /// `true` if `T::type` exists and names a type; `false` otherwise. /// \ingroup trait template META_INLINE_VAR constexpr bool is_trait_v = Trait; /// `true` if `T::invoke` exists and names a class template; `false` otherwise. /// \ingroup trait template META_INLINE_VAR constexpr bool is_callable_v = Invocable; #else // ^^^ Concepts / No concepts vvv /// \cond namespace detail { template META_INLINE_VAR constexpr bool is_trait_ = false; template META_INLINE_VAR constexpr bool is_trait_> = true; template META_INLINE_VAR constexpr bool is_callable_ = false; template META_INLINE_VAR constexpr bool is_callable_>> = true; } // namespace detail /// \endcond /// `true` if `T::type` exists and names a type; `false` otherwise. /// \ingroup trait template META_INLINE_VAR constexpr bool is_trait_v = detail::is_trait_; /// `true` if `T::invoke` exists and names a class template; `false` otherwise. /// \ingroup trait template META_INLINE_VAR constexpr bool is_callable_v = detail::is_callable_; #endif // Concepts vs. variable templates /// An alias for `std::true_type` if `T::type` exists and names a type; otherwise, it's an /// alias for `std::false_type`. /// \ingroup trait template using is_trait = bool_>; /// An alias for `std::true_type` if `T::invoke` exists and names a class template; /// otherwise, it's an alias for `std::false_type`. /// \ingroup trait template using is_callable = bool_>; #else // ^^^ META_CXX_VARIABLE_TEMPLATES / !META_CXX_VARIABLE_TEMPLATES vvv /// \cond namespace detail { template struct is_trait_ { using type = std::false_type; }; template struct is_trait_> { using type = std::true_type; }; template struct is_callable_ { using type = std::false_type; }; template struct is_callable_>> { using type = std::true_type; }; } // namespace detail /// \endcond template using is_trait = _t>; /// An alias for `std::true_type` if `T::invoke` exists and names a class /// template or alias template; otherwise, it's an alias for /// `std::false_type`. /// \ingroup trait template using is_callable = _t>; #endif /// \cond namespace detail { #ifdef META_CONCEPT template