├── _vendor ├── .gitignore ├── catch-ext │ ├── update.py │ └── include │ │ ├── module.modulemap │ │ └── catch_ext.hpp ├── fmt │ ├── update.py │ └── include │ │ └── fmt │ │ ├── module.modulemap │ │ ├── all.hpp │ │ ├── ostream.cc │ │ ├── time.h │ │ ├── ostream.h │ │ └── string.h ├── range-v3 │ ├── include │ │ ├── module.modulemap │ │ ├── range │ │ │ └── v3 │ │ │ │ ├── utility │ │ │ │ ├── optional.hpp │ │ │ │ ├── polymorphic_cast.hpp │ │ │ │ ├── static_const.hpp │ │ │ │ ├── nullptr_v.hpp │ │ │ │ ├── tagged_tuple.hpp │ │ │ │ ├── get.hpp │ │ │ │ ├── unreachable.hpp │ │ │ │ ├── copy.hpp │ │ │ │ ├── infinity.hpp │ │ │ │ └── iterator_traits.hpp │ │ │ │ ├── all.hpp │ │ │ │ ├── numeric.hpp │ │ │ │ ├── core.hpp │ │ │ │ ├── empty.hpp │ │ │ │ ├── action.hpp │ │ │ │ ├── front.hpp │ │ │ │ ├── algorithm │ │ │ │ ├── tagspec.hpp │ │ │ │ ├── fill_n.hpp │ │ │ │ ├── fill.hpp │ │ │ │ ├── generate_n.hpp │ │ │ │ ├── copy_n.hpp │ │ │ │ ├── generate.hpp │ │ │ │ ├── for_each.hpp │ │ │ │ ├── all_of.hpp │ │ │ │ ├── any_of.hpp │ │ │ │ ├── none_of.hpp │ │ │ │ ├── move.hpp │ │ │ │ ├── count_if.hpp │ │ │ │ ├── move_backward.hpp │ │ │ │ ├── count.hpp │ │ │ │ ├── aux_ │ │ │ │ │ ├── lower_bound_n.hpp │ │ │ │ │ ├── partition_point_n.hpp │ │ │ │ │ ├── upper_bound_n.hpp │ │ │ │ │ ├── merge_n_with_buffer.hpp │ │ │ │ │ └── sort_n_with_buffer.hpp │ │ │ │ ├── upper_bound.hpp │ │ │ │ ├── lower_bound.hpp │ │ │ │ ├── max_element.hpp │ │ │ │ ├── min_element.hpp │ │ │ │ ├── rotate_copy.hpp │ │ │ │ ├── copy.hpp │ │ │ │ ├── copy_backward.hpp │ │ │ │ ├── reverse_copy.hpp │ │ │ │ ├── replace.hpp │ │ │ │ ├── replace_if.hpp │ │ │ │ ├── is_sorted.hpp │ │ │ │ ├── reverse.hpp │ │ │ │ ├── find.hpp │ │ │ │ ├── remove.hpp │ │ │ │ ├── binary_search.hpp │ │ │ │ ├── adjacent_find.hpp │ │ │ │ ├── copy_if.hpp │ │ │ │ ├── remove_if.hpp │ │ │ │ ├── remove_copy.hpp │ │ │ │ ├── partial_sort.hpp │ │ │ │ ├── find_if.hpp │ │ │ │ ├── unique.hpp │ │ │ │ ├── max.hpp │ │ │ │ ├── min.hpp │ │ │ │ ├── find_if_not.hpp │ │ │ │ ├── is_partitioned.hpp │ │ │ │ ├── remove_copy_if.hpp │ │ │ │ ├── lexicographical_compare.hpp │ │ │ │ ├── shuffle.hpp │ │ │ │ └── is_sorted_until.hpp │ │ │ │ ├── back.hpp │ │ │ │ ├── at.hpp │ │ │ │ ├── numeric │ │ │ │ ├── iota.hpp │ │ │ │ └── accumulate.hpp │ │ │ │ ├── range_for.hpp │ │ │ │ ├── view │ │ │ │ ├── filter.hpp │ │ │ │ ├── unbounded.hpp │ │ │ │ ├── unique.hpp │ │ │ │ ├── empty.hpp │ │ │ │ └── counted.hpp │ │ │ │ ├── detail │ │ │ │ └── optional.hpp │ │ │ │ ├── view.hpp │ │ │ │ ├── getlines.hpp │ │ │ │ └── action │ │ │ │ └── join.hpp │ │ └── meta │ │ │ └── meta_fwd.hpp │ └── update.py ├── json │ └── update.py └── catch │ ├── include │ ├── module.modulemap │ └── catch_with_main.hpp │ └── update.py ├── list-and-map ├── _vendor ├── build.sh ├── CMakeLists.txt └── main.py ├── project-setup ├── _vendor ├── build.sh ├── main.py ├── CMakeLists.txt └── main.cpp ├── text-manipulation ├── _vendor ├── build.sh ├── CMakeLists.txt └── main.py ├── value-or-reference ├── cpp │ ├── _vendor │ └── CMakeLists.txt ├── php │ └── main.php ├── python │ └── main.py └── golang │ └── src │ └── test.go ├── README.md ├── book.json ├── SUMMARY.md └── .gitignore /_vendor/.gitignore: -------------------------------------------------------------------------------- 1 | _update 2 | -------------------------------------------------------------------------------- /list-and-map/_vendor: -------------------------------------------------------------------------------- 1 | ../_vendor -------------------------------------------------------------------------------- /project-setup/_vendor: -------------------------------------------------------------------------------- 1 | ../_vendor -------------------------------------------------------------------------------- /_vendor/catch-ext/update.py: -------------------------------------------------------------------------------- 1 | # home made -------------------------------------------------------------------------------- /text-manipulation/_vendor: -------------------------------------------------------------------------------- 1 | ../_vendor -------------------------------------------------------------------------------- /value-or-reference/cpp/_vendor: -------------------------------------------------------------------------------- 1 | ../../_vendor -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 一个非C++程序员的学习笔记,适合其他语言的程序员了解现代C++已经是如何地与过去不同了。 -------------------------------------------------------------------------------- /list-and-map/build.sh: -------------------------------------------------------------------------------- 1 | cd build 2 | make -j 8 && ./list-and-map 3 | -------------------------------------------------------------------------------- /_vendor/fmt/update.py: -------------------------------------------------------------------------------- 1 | # https://github.com/fmtlib/fmt.git 2 | # fmt => include/_fmt -------------------------------------------------------------------------------- /_vendor/catch-ext/include/module.modulemap: -------------------------------------------------------------------------------- 1 | module catch_ext { 2 | umbrella "." 3 | export * 4 | } -------------------------------------------------------------------------------- /_vendor/range-v3/include/module.modulemap: -------------------------------------------------------------------------------- 1 | module range_v3 { 2 | umbrella "." 3 | export * 4 | } -------------------------------------------------------------------------------- /_vendor/json/update.py: -------------------------------------------------------------------------------- 1 | # https://github.com/nlohmann/json.git 2 | # v2.0.2 3 | # src/json.hpp => include/json.hpp -------------------------------------------------------------------------------- /project-setup/build.sh: -------------------------------------------------------------------------------- 1 | cd build 2 | cmake -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D USE_MODULES=on ../ 3 | make -j 8 4 | -------------------------------------------------------------------------------- /_vendor/catch/include/module.modulemap: -------------------------------------------------------------------------------- 1 | module catch { 2 | requires cplusplus11 3 | header "catch_with_main.hpp" 4 | export * 5 | } -------------------------------------------------------------------------------- /_vendor/range-v3/update.py: -------------------------------------------------------------------------------- 1 | # https://github.com/ericniebler/range-v3.git 2 | # 8f2bd6ea2a83b9f0ad2d5c0a6ebe5319fe2256df 3 | # include => include -------------------------------------------------------------------------------- /text-manipulation/build.sh: -------------------------------------------------------------------------------- 1 | cd build 2 | cmake -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D USE_MODULES=on ../ 3 | make -j 8 4 | -------------------------------------------------------------------------------- /book.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["disqus"], 3 | "pluginsConfig": { 4 | "disqus": { 5 | "shortName": "modern-cpp-howto" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /_vendor/catch/update.py: -------------------------------------------------------------------------------- 1 | # https://github.com/philsquared/Catch.git 2 | # v1.5.6 3 | # single_include/catch.hpp => include/catch.hpp 4 | # include/catch_with_main.hpp => include/catch_with_main.hpp -------------------------------------------------------------------------------- /_vendor/fmt/include/fmt/module.modulemap: -------------------------------------------------------------------------------- 1 | module fmt { 2 | requires cplusplus11 3 | header "format.h" 4 | header "ostream.h" 5 | header "posix.h" 6 | header "printf.h" 7 | header "string.h" 8 | header "time.h" 9 | export * 10 | } -------------------------------------------------------------------------------- /_vendor/fmt/include/fmt/all.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FMT_FORMAT_ALL_H_ 2 | #define FMT_FORMAT_ALL_H_ 3 | #include "fmt/format.cc" 4 | #include "fmt/ostream.cc" 5 | #include "fmt/posix.cc" 6 | #include "fmt/printf.h" 7 | #include "fmt/string.h" 8 | #include "fmt/time.h" 9 | #endif // FMT_FORMAT_ALL_H_ -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | ## 基本语言设施 4 | * [简介](README.md) 5 | * [工程管理](project-setup/chapter.md) 6 | * [list 和 map](list-and-map/chapter.md) 7 | * [value 还是 reference](value-or-reference/chapter.md) 8 | * [exception](exception/chapter.md) 9 | * [concurrency](concurrency/chapter.md) 10 | 11 | ## 日常工作 12 | * [文本处理](text-manipulation/chapter.md) 13 | * json serlization 14 | * file operation 15 | * urllib2 & http server 16 | * template 17 | * sql 18 | * subprocess 19 | 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node rules: 2 | ## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 3 | .grunt 4 | 5 | ## Dependency directory 6 | ## Commenting this out is preferred by some people, see 7 | ## https://docs.npmjs.com/misc/faq#should-i-check-my-node_modules-folder-into-git 8 | node_modules 9 | 10 | # Book build output 11 | _book 12 | 13 | # eBook build output 14 | *.epub 15 | *.mobi 16 | *.pdf 17 | .idea 18 | *.iml 19 | CMakeLists.txt.user 20 | build 21 | -------------------------------------------------------------------------------- /project-setup/main.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | 4 | def fib(n): 5 | if n <= 1: 6 | return n 7 | else: 8 | return fib(n - 1) + fib(n - 2) 9 | 10 | 11 | class FibTest(unittest.TestCase): 12 | def test_fib_0(self): 13 | self.assertEqual(0, fib(0)) 14 | 15 | def test_fib_1(self): 16 | self.assertEqual(1, fib(1)) 17 | 18 | def test_fib_5(self): 19 | self.assertEqual(5, fib(5)) 20 | 21 | def test_assert_list_equals(self): 22 | self.assertListEqual([1, 2, 3], [1, 2, 4]) 23 | -------------------------------------------------------------------------------- /_vendor/catch/include/catch_with_main.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by Phil on 01/11/2010. 3 | * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | #ifndef TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED 9 | #define TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED 10 | 11 | #define CATCH_CONFIG_MAIN 12 | #include "catch.hpp" 13 | 14 | #endif // TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED 15 | -------------------------------------------------------------------------------- /project-setup/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(unit-testing) 3 | 4 | include_directories(_vendor/catch/include) 5 | include_directories(_vendor/catch-ext/include) 6 | include_directories(_vendor/range-v3/include) 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++") 8 | if (USE_MODULES) 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++ -fno-autolink -fmodules -fmodules-cache-path=${CMAKE_SOURCE_DIR}/build") 10 | endif(USE_MODULES) 11 | set(SOURCE_FILES main.cpp) 12 | add_executable(unit-testing ${SOURCE_FILES}) 13 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/optional.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_OPTIONAL_HPP 15 | #define RANGES_V3_UTILITY_OPTIONAL_HPP 16 | 17 | #include 18 | #include 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /text-manipulation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(text-manipulation) 3 | 4 | include_directories(_vendor/catch/include) 5 | include_directories(_vendor/catch-ext/include) 6 | include_directories(_vendor/range-v3/include) 7 | include_directories(_vendor/fmt/include) 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++") 9 | if (USE_MODULES) 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++ -fno-autolink -fmodules -fmodules-cache-path=${CMAKE_SOURCE_DIR}/build") 11 | endif(USE_MODULES) 12 | set(SOURCE_FILES main.cpp) 13 | add_executable(text-manipulation ${SOURCE_FILES}) 14 | -------------------------------------------------------------------------------- /value-or-reference/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.6) 2 | project(value-or-reference) 3 | 4 | include_directories(_vendor/catch/include) 5 | include_directories(_vendor/range-v3/include) 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++") 7 | if (USE_MODULES) 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++ -fno-autolink -fmodules -fmodules-cache-path=${CMAKE_SOURCE_DIR}/build") 9 | endif(USE_MODULES) 10 | set(SOURCE_FILES main.cpp) 11 | add_executable(value-or-reference ${SOURCE_FILES}) 12 | 13 | find_package (Threads) 14 | target_link_libraries (value-or-reference ${CMAKE_THREAD_LIBS_INIT}) 15 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/all.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013,2014. 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_ALL_HPP 15 | #define RANGES_V3_ALL_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /list-and-map/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(list-and-map) 3 | 4 | include_directories(_vendor/catch/include) 5 | include_directories(_vendor/catch-ext/include) 6 | include_directories(_vendor/range-v3/include) 7 | include_directories(_vendor/json/include) 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++ -g") 9 | if (USE_MODULES) 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++ -fno-autolink -fmodules -fmodules-cache-path=${CMAKE_SOURCE_DIR}/build") 11 | endif() 12 | if (CMAKE_BUILD_TYPE STREQUAL "Debug") 13 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") 14 | endif() 15 | set(SOURCE_FILES main.cpp) 16 | add_executable(list-and-map ${SOURCE_FILES}) 17 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/numeric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file numeric.hpp 3 | /// Contains range-based versions of the numeric algorithms 4 | // 5 | // Copyright Eric Niebler 2014 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See 8 | // accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | #ifndef RANGES_V3_NUMERIC_HPP 12 | #define RANGES_V3_NUMERIC_HPP 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/polymorphic_cast.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Kevlin Henney and Dave Abrahams 1999. 2 | // Distributed under the Boost 3 | // Software License, Version 1.0. (See accompanying file 4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef RANGES_V3_UTILITY_POLYMORPHIC_CAST_HPP 7 | #define RANGES_V3_UTILITY_POLYMORPHIC_CAST_HPP 8 | 9 | namespace ranges 10 | { 11 | inline namespace v3 12 | { 13 | template 14 | inline Target polymorphic_downcast(Source* x) 15 | { 16 | RANGES_ASSERT(dynamic_cast(x) == x); 17 | return static_cast(x); 18 | } 19 | } 20 | } 21 | 22 | #endif // RANGES_V3_UTILITY_POLYMORPHIC_CAST_HPP 23 | -------------------------------------------------------------------------------- /value-or-reference/php/main.php: -------------------------------------------------------------------------------- 1 | field = 2; 25 | } 26 | 27 | $local_variable = 1; 28 | modify_single_value($local_variable); 29 | var_dump($local_variable); // 1 30 | 31 | $local_variable = 1; 32 | modify_single_reference($local_variable); 33 | var_dump($local_variable); // 2 34 | 35 | $local_variable = [1, 1]; 36 | modify_list_value($local_variable); 37 | var_dump($local_variable); // [1, 1] 38 | 39 | $local_variable = new MyStruct(); 40 | $local_variable->field = 1; 41 | modify_struct_value($local_variable); 42 | var_dump($local_variable); // 2, 和 array 不同,object 是不拷贝的 43 | -------------------------------------------------------------------------------- /value-or-reference/python/main.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | 4 | class MyStruct: 5 | def __init__(self): 6 | self.field = None 7 | 8 | 9 | class Test(unittest.TestCase): 10 | def test_pass_single_value(self): 11 | local_variable = 1 12 | print(id(local_variable)) 13 | modify_single_value(local_variable) 14 | print(local_variable) # 1 15 | 16 | def test_pass_list_value(self): 17 | local_variable = [1, 1] 18 | modify_list_value(local_variable) 19 | print(local_variable) # [1, 2] 20 | 21 | def test_pass_struct_value(self): 22 | local_variable = MyStruct() 23 | local_variable.field = 1 24 | modify_struct_value(local_variable) 25 | print(local_variable.field) # 2 26 | 27 | 28 | def modify_single_value(single): 29 | print(id(single)) 30 | single = 2 31 | 32 | 33 | def modify_list_value(list): 34 | list[1] = 2 35 | 36 | 37 | def modify_struct_value(struct): 38 | struct.field = 2 39 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/static_const.hpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2013-2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #ifndef RANGES_V3_UTILITY_STATIC_CONST_HPP 14 | #define RANGES_V3_UTILITY_STATIC_CONST_HPP 15 | 16 | #include 17 | 18 | namespace ranges 19 | { 20 | inline namespace v3 21 | { 22 | /// \ingroup group-utility 23 | 24 | template 25 | struct static_const 26 | { 27 | static constexpr T value {}; 28 | }; 29 | 30 | /// \ingroup group-utility 31 | /// \sa `static_const` 32 | template 33 | constexpr T static_const::value; 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/nullptr_v.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013,2014. 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_NULLVAL_HPP 15 | #define RANGES_V3_UTILITY_NULLVAL_HPP 16 | 17 | #include 18 | 19 | namespace ranges 20 | { 21 | inline namespace v3 22 | { 23 | /// \ingroup group-utility 24 | template 25 | constexpr T *_nullptr_v() 26 | { 27 | return nullptr; 28 | } 29 | 30 | #if RANGES_CXX_VARIABLE_TEMPLATES 31 | /// \ingroup group-utility 32 | template 33 | constexpr T *nullptr_v = nullptr; 34 | #endif 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /_vendor/fmt/include/fmt/ostream.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Formatting library for C++ - std::ostream support 3 | 4 | Copyright (c) 2012 - 2016, Victor Zverovich 5 | All rights reserved. 6 | 7 | For the license information refer to format.h. 8 | */ 9 | 10 | #include "fmt/ostream.h" 11 | 12 | namespace fmt { 13 | 14 | namespace internal { 15 | FMT_FUNC void write(std::ostream &os, Writer &w) { 16 | const char *data = w.data(); 17 | typedef internal::MakeUnsigned::Type UnsignedStreamSize; 18 | UnsignedStreamSize size = w.size(); 19 | UnsignedStreamSize max_size = 20 | internal::to_unsigned((std::numeric_limits::max)()); 21 | do { 22 | UnsignedStreamSize n = size <= max_size ? size : max_size; 23 | os.write(data, static_cast(n)); 24 | data += n; 25 | size -= n; 26 | } while (size != 0); 27 | } 28 | } 29 | 30 | FMT_FUNC void print(std::ostream &os, CStringRef format_str, ArgList args) { 31 | MemoryWriter w; 32 | w.write(format_str, args); 33 | internal::write(os, w); 34 | } 35 | } // namespace fmt 36 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/tagged_tuple.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2015 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | 13 | #ifndef RANGES_V3_UTILITY_TAGGED_TUPLE_HPP 14 | #define RANGES_V3_UTILITY_TAGGED_TUPLE_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | template 25 | using tagged_tuple = 26 | tagged...>, detail::tag_spec...>; 27 | 28 | template 29 | constexpr tagged_tuple)...> 30 | make_tagged_tuple(Ts &&... ts) 31 | { 32 | return tagged_tuple)...>{detail::forward(ts)...}; 33 | } 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/get.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_GET_HPP 15 | #define RANGES_V3_UTILITY_GET_HPP 16 | 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | /// \addtogroup group-utility Utility 25 | /// @{ 26 | /// 27 | template 28 | T & get(meta::id_t & value) 29 | { 30 | return value; 31 | } 32 | 33 | template 34 | T const & get(meta::id_t const & value) 35 | { 36 | return value; 37 | } 38 | 39 | template 40 | T && get(meta::id_t && value) 41 | { 42 | return std::move(value); 43 | } 44 | /// @} 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/core.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_CORE_HPP 15 | #define RANGES_V3_CORE_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/empty.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_EMPTY_HPP 15 | #define RANGES_V3_EMPTY_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace ranges 23 | { 24 | inline namespace v3 25 | { 26 | /// \ingroup group-core 27 | struct empty_fn 28 | { 29 | /// \return `begin(rng) == end(rng)` 30 | template())> 32 | RANGES_CXX14_CONSTEXPR 33 | bool operator()(Rng &&rng) const 34 | { 35 | return begin(rng) == end(rng); 36 | } 37 | }; 38 | 39 | /// \ingroup group-core 40 | /// \sa `empty_fn` 41 | RANGES_INLINE_VARIABLE(empty_fn, empty) 42 | } 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/action.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_ACTION_HPP 15 | #define RANGES_V3_ACTION_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/front.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_FRONT_HPP 15 | #define RANGES_V3_FRONT_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | /// \ingroup group-core 29 | struct front_fn 30 | { 31 | /// \return `*begin(rng)` 32 | template())> 34 | RANGES_CXX14_CONSTEXPR 35 | range_reference_t operator()(Rng &&rng) const 36 | { 37 | return *begin(rng); 38 | } 39 | }; 40 | 41 | /// \ingroup group-core 42 | /// \sa `front_fn` 43 | RANGES_INLINE_VARIABLE(front_fn, front) 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /value-or-reference/golang/src/test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "unsafe" 6 | ) 7 | 8 | type MyStruct struct { 9 | field int 10 | } 11 | 12 | func main() { 13 | { 14 | local_variable := 1 15 | modify_single_value(local_variable) 16 | fmt.Println(local_variable) // 1 17 | } 18 | { 19 | local_variable := 1 20 | modify_single_pointer(&local_variable) 21 | fmt.Println(local_variable) // 2 22 | } 23 | { 24 | local_variable := []int{1, 1} 25 | modify_list_value(local_variable) 26 | fmt.Println(local_variable) // []int{1, 2} 27 | } 28 | { 29 | local_variable := MyStruct{1} 30 | fmt.Println(unsafe.Pointer(&local_variable)) 31 | local_variable.modify_struct_value() 32 | fmt.Println(local_variable) // {1} 33 | copied := local_variable.copy_my_self() 34 | fmt.Println(unsafe.Pointer(&copied)) 35 | } 36 | } 37 | 38 | func modify_single_value(single int) { 39 | single = 2 40 | } 41 | 42 | func modify_single_pointer(single *int) { 43 | *single = 2 44 | } 45 | 46 | func modify_list_value(list []int) { 47 | list[1] = 2 48 | } 49 | 50 | // 何时使用指针 51 | // https://golang.org/doc/faq#methods_on_values_or_pointers 52 | func (self MyStruct) modify_struct_value() { 53 | fmt.Println(unsafe.Pointer(&self)) 54 | self.field = 2 55 | } 56 | func (self MyStruct) copy_my_self() MyStruct { 57 | fmt.Println(unsafe.Pointer(&self)) 58 | return self 59 | } 60 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/algorithm/tagspec.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2015 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | 13 | #ifndef RANGES_V3_ALGORITHM_TAGSPEC_HPP 14 | #define RANGES_V3_ALGORITHM_TAGSPEC_HPP 15 | 16 | #include 17 | #include 18 | 19 | namespace ranges 20 | { 21 | inline namespace v3 22 | { 23 | RANGES_DEFINE_TAG_SPECIFIER(in) 24 | RANGES_DEFINE_TAG_SPECIFIER(in1) 25 | RANGES_DEFINE_TAG_SPECIFIER(in2) 26 | RANGES_DEFINE_TAG_SPECIFIER(out) 27 | RANGES_DEFINE_TAG_SPECIFIER(out1) 28 | RANGES_DEFINE_TAG_SPECIFIER(out2) 29 | RANGES_DEFINE_TAG_SPECIFIER(fun) 30 | RANGES_DEFINE_TAG_SPECIFIER(min) 31 | RANGES_DEFINE_TAG_SPECIFIER(max) 32 | RANGES_DEFINE_TAG_SPECIFIER(begin) 33 | RANGES_DEFINE_TAG_SPECIFIER(end) 34 | 35 | RANGES_DEFINE_TAG_SPECIFIER(current) 36 | RANGES_DEFINE_TAG_SPECIFIER(engine) 37 | RANGES_DEFINE_TAG_SPECIFIER(range) 38 | RANGES_DEFINE_TAG_SPECIFIER(size) 39 | } 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/back.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_BACK_HPP 15 | #define RANGES_V3_BACK_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | /// \ingroup group-core 29 | struct back_fn 30 | { 31 | /// \return `*prev(end(rng))` 32 | template() && BidirectionalRange())> 34 | RANGES_CXX14_CONSTEXPR 35 | range_reference_t operator()(Rng &&rng) const 36 | { 37 | return *prev(end(rng)); 38 | } 39 | }; 40 | 41 | /// \ingroup group-core 42 | /// \sa `back_fn` 43 | RANGES_INLINE_VARIABLE(back_fn, back) 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/at.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_AT_HPP 15 | #define RANGES_V3_AT_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | /// \ingroup group-core 29 | struct at_fn 30 | { 31 | /// \return `begin(rng)[n]` 32 | template())> 34 | RANGES_CXX14_CONSTEXPR 35 | auto operator()(Rng &&rng, range_difference_t n) const -> 36 | decltype(begin(rng)[n]) 37 | { 38 | return begin(rng)[n]; 39 | } 40 | }; 41 | 42 | /// \ingroup group-core 43 | /// \sa `at_fn` 44 | RANGES_INLINE_VARIABLE(at_fn, at) 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/unreachable.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | #ifndef RANGES_V3_UTILITY_UNREACHABLE_HPP 14 | #define RANGES_V3_UTILITY_UNREACHABLE_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | /// \addtogroup group-utility 25 | /// @{ 26 | struct unreachable 27 | { 28 | template 29 | friend constexpr bool operator==(T const &, unreachable) 30 | { 31 | return false; 32 | } 33 | template 34 | friend constexpr bool operator==(unreachable, T const &) 35 | { 36 | return false; 37 | } 38 | template 39 | friend constexpr bool operator!=(T const &, unreachable) 40 | { 41 | return true; 42 | } 43 | template 44 | friend constexpr bool operator!=(unreachable, T const &) 45 | { 46 | return true; 47 | } 48 | }; 49 | /// @} 50 | } 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/numeric/iota.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | #ifndef RANGES_V3_NUMERIC_IOTA_HPP 14 | #define RANGES_V3_NUMERIC_IOTA_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace ranges 23 | { 24 | inline namespace v3 25 | { 26 | struct iota_fn 27 | { 28 | template() && Sentinel() && 30 | WeaklyIncrementable())> 31 | O operator()(O begin, S end, T val) const 32 | { 33 | for(; begin != end; ++begin, ++val) 34 | *begin = detail::as_const(val); 35 | return begin; 36 | } 37 | 38 | template, 39 | CONCEPT_REQUIRES_(OutputRange() && WeaklyIncrementable())> 40 | O operator()(Rng &rng, T val) const 41 | { 42 | return (*this)(begin(rng), end(rng), std::move(val)); 43 | } 44 | }; 45 | 46 | RANGES_INLINE_VARIABLE(iota_fn, iota) 47 | } 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/copy.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_COPY_HPP 15 | #define RANGES_V3_UTILITY_COPY_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace ranges 22 | { 23 | inline namespace v3 24 | { 25 | /// \addtogroup group-utility 26 | /// @{ 27 | namespace aux 28 | { 29 | struct copy_fn : copy_tag 30 | { 31 | template, T &&>())> 33 | detail::decay_t operator()(T && t) const 34 | { 35 | return static_cast(t); 36 | } 37 | }; 38 | 39 | /// \ingroup group-utility 40 | /// \sa `copy_fn` 41 | RANGES_INLINE_VARIABLE(copy_fn, copy) 42 | 43 | /// \ingroup group-utility 44 | /// \sa `copy_fn` 45 | template, T &&>())> 47 | detail::decay_t operator|(T && t, copy_fn) 48 | { 49 | return static_cast(t); 50 | } 51 | } 52 | /// @} 53 | } 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /_vendor/fmt/include/fmt/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | Formatting library for C++ - time formatting 3 | 4 | Copyright (c) 2012 - 2016, Victor Zverovich 5 | All rights reserved. 6 | 7 | For the license information refer to format.h. 8 | */ 9 | 10 | #ifndef FMT_TIME_H_ 11 | #define FMT_TIME_H_ 12 | 13 | #include "fmt/format.h" 14 | #include 15 | 16 | namespace fmt { 17 | template 18 | void format_arg(BasicFormatter &f, 19 | const char *&format_str, const std::tm &tm) { 20 | if (*format_str == ':') 21 | ++format_str; 22 | const char *end = format_str; 23 | while (*end && *end != '}') 24 | ++end; 25 | if (*end != '}') 26 | FMT_THROW(FormatError("missing '}' in format string")); 27 | internal::MemoryBuffer format; 28 | format.append(format_str, end + 1); 29 | format[format.size() - 1] = '\0'; 30 | Buffer &buffer = f.writer().buffer(); 31 | std::size_t start = buffer.size(); 32 | for (;;) { 33 | std::size_t size = buffer.capacity() - start; 34 | std::size_t count = std::strftime(&buffer[start], size, &format[0], &tm); 35 | if (count != 0) { 36 | buffer.resize(start + count); 37 | break; 38 | } 39 | if (size >= format.size() * 256) { 40 | // If the buffer is 256 times larger than the format string, assume 41 | // that `strftime` gives an empty result. There doesn't seem to be a 42 | // better way to distinguish the two cases: 43 | // https://github.com/fmtlib/fmt/issues/367 44 | break; 45 | } 46 | const std::size_t MIN_GROWTH = 10; 47 | buffer.reserve(buffer.capacity() + (size > MIN_GROWTH ? size : MIN_GROWTH)); 48 | } 49 | format_str = end + 1; 50 | } 51 | } 52 | 53 | #endif // FMT_TIME_H_ 54 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/algorithm/fill_n.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | #ifndef RANGES_V3_ALGORITHM_FILL_N_HPP 14 | #define RANGES_V3_ALGORITHM_FILL_N_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace ranges 26 | { 27 | inline namespace v3 28 | { 29 | /// \addtogroup group-algorithms 30 | /// @{ 31 | struct fill_n_fn 32 | { 33 | template())> 35 | O operator()(O begin, iterator_difference_t n, V const & val) const 36 | { 37 | RANGES_ASSERT(n >= 0); 38 | auto norig = n; 39 | auto b = uncounted(begin); 40 | for(; n != 0; ++b, --n) 41 | *b = val; 42 | return recounted(begin, b, norig); 43 | } 44 | }; 45 | 46 | /// \sa `fill_n_fn` 47 | /// \ingroup group-algorithms 48 | RANGES_INLINE_VARIABLE(fill_n_fn, fill_n) 49 | /// @} 50 | } // namespace v3 51 | } // namespace ranges 52 | 53 | #endif // include guard 54 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/range_for.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_RANGE_FOR_HPP 15 | #define RANGES_V3_RANGE_FOR_HPP 16 | 17 | #include 18 | #include 19 | 20 | #if RANGES_CXX_RANGE_BASED_FOR < RANGES_CXX_RANGE_BASED_FOR_17 21 | /// A range-based for macro, basically a hack until the build-in range-for can handle Ranges 22 | /// which have a different type for begin and end. 23 | /// \ingroup range-core 24 | #define RANGES_FOR(VAR_DECL, ...) \ 25 | if(bool _range_v3_done = false) {} \ 26 | else for(auto && _range_v3_rng = (__VA_ARGS__); !_range_v3_done;) \ 27 | for(auto _range_v3_begin = ranges::begin(_range_v3_rng); !_range_v3_done; \ 28 | _range_v3_done = true) \ 29 | for(auto _range_v3_end = ranges::end(_range_v3_rng); \ 30 | !_range_v3_done && _range_v3_begin != _range_v3_end; ++_range_v3_begin) \ 31 | if(!(_range_v3_done = true)) {} \ 32 | else for(VAR_DECL = *_range_v3_begin; _range_v3_done; _range_v3_done = false) \ 33 | /**/ 34 | 35 | #else 36 | #define RANGES_FOR(VAR_DECL, ...) for(VAR_DECL : (__VA_ARGS__)) 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/utility/infinity.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_INFINITY_HPP 15 | #define RANGES_V3_UTILITY_INFINITY_HPP 16 | 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | /// \cond 25 | struct infinity 26 | { 27 | }; 28 | 29 | constexpr bool operator==(infinity, infinity) 30 | { 31 | return true; 32 | } 33 | constexpr bool operator!=(infinity, infinity) 34 | { 35 | return false; 36 | } 37 | 38 | template())> 40 | constexpr bool operator==(Integer, infinity) 41 | { 42 | return false; 43 | } 44 | template())> 46 | constexpr bool operator==(infinity, Integer) 47 | { 48 | return false; 49 | } 50 | template())> 52 | constexpr bool operator!=(Integer, infinity) 53 | { 54 | return true; 55 | } 56 | template())> 58 | constexpr bool operator!=(infinity, Integer) 59 | { 60 | return true; 61 | } 62 | /// \endcond 63 | } 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/view/filter.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_VIEW_FILTER_HPP 15 | #define RANGES_V3_VIEW_FILTER_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace ranges 23 | { 24 | inline namespace v3 25 | { 26 | namespace view 27 | { 28 | struct filter_fn 29 | { 30 | template 31 | remove_if_view, logical_negate> 32 | operator()(Rng && rng, Pred pred) const 33 | { 34 | CONCEPT_ASSERT(Range()); 35 | CONCEPT_ASSERT(IndirectCallablePredicate>()); 36 | return {all(std::forward(rng)), not_(std::move(pred))}; 37 | } 38 | template 39 | auto operator()(Pred pred) const -> 40 | decltype(make_pipeable(std::bind(*this, std::placeholders::_1, 41 | protect(std::move(pred))))) 42 | { 43 | return make_pipeable(std::bind(*this, std::placeholders::_1, 44 | protect(std::move(pred)))); 45 | } 46 | }; 47 | 48 | /// \relates filter_fn 49 | /// \ingroup group-views 50 | RANGES_INLINE_VARIABLE(filter_fn, filter) 51 | } 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/algorithm/fill.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | #ifndef RANGES_V3_ALGORITHM_FILL_HPP 14 | #define RANGES_V3_ALGORITHM_FILL_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace ranges 24 | { 25 | inline namespace v3 26 | { 27 | /// \addtogroup group-algorithms 28 | /// @{ 29 | struct fill_fn 30 | { 31 | template() && Sentinel())> 33 | O operator()(O begin, S end, V const & val) const 34 | { 35 | for(; begin != end; ++begin) 36 | *begin = val; 37 | return begin; 38 | } 39 | 40 | template, 42 | CONCEPT_REQUIRES_(OutputRange())> 43 | range_safe_iterator_t operator()(Rng &&rng, V const & val) const 44 | { 45 | return (*this)(begin(rng), end(rng), val); 46 | } 47 | }; 48 | 49 | /// \sa `fill_fn` 50 | /// \ingroup group-algorithms 51 | RANGES_INLINE_VARIABLE(with_braced_init_args, fill) 52 | /// @} 53 | } // namespace v3 54 | } // namespace ranges 55 | 56 | #endif // include guard 57 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/view/unbounded.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright Eric Niebler 2014 3 | // 4 | // Use, modification and distribution is subject to the 5 | // Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at 7 | // http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // Project home: https://github.com/ericniebler/range-v3 10 | // 11 | 12 | #ifndef RANGES_V3_VIEW_UNBOUNDED_HPP 13 | #define RANGES_V3_VIEW_UNBOUNDED_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | /// \addtogroup group-views 25 | /// @{ 26 | template 27 | struct unbounded_view 28 | : view_interface, infinite> 29 | { 30 | private: 31 | I it_; 32 | public: 33 | constexpr explicit unbounded_view(I it) 34 | : it_(detail::move(it)) 35 | {} 36 | constexpr I begin() const 37 | { 38 | return it_; 39 | } 40 | constexpr unreachable end() const 41 | { 42 | return {}; 43 | } 44 | }; 45 | 46 | namespace view 47 | { 48 | struct unbounded_fn 49 | { 50 | template 51 | constexpr unbounded_view operator()(I it) const 52 | { 53 | CONCEPT_ASSERT(InputIterator()); 54 | return unbounded_view{detail::move(it)}; 55 | } 56 | }; 57 | 58 | /// \relates unbounded_fn 59 | /// \ingroup group-views 60 | RANGES_INLINE_VARIABLE(unbounded_fn, unbounded) 61 | } 62 | /// @} 63 | } 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/range/v3/algorithm/generate_n.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | #ifndef RANGES_V3_ALGORITHM_GENERATE_N_HPP 14 | #define RANGES_V3_ALGORITHM_GENERATE_N_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace ranges 29 | { 30 | inline namespace v3 31 | { 32 | /// \addtogroup group-algorithms 33 | /// @{ 34 | struct generate_n_fn 35 | { 36 | template() && 38 | OutputIterator &&>())> 39 | tagged_pair 40 | operator()(O begin, iterator_difference_t n, F fun) const 41 | { 42 | RANGES_ASSERT(n >= 0); 43 | auto norig = n; 44 | auto b = uncounted(begin); 45 | for(; 0 != n; ++b, --n) 46 | *b = fun(); 47 | return {recounted(begin, b, norig), fun}; 48 | } 49 | }; 50 | 51 | /// \sa `generate_n_fn` 52 | /// \ingroup group-algorithms 53 | RANGES_INLINE_VARIABLE(generate_n_fn, generate_n) 54 | // @} 55 | } // namespace v3 56 | } // namespace ranges 57 | 58 | #endif // include guard 59 | -------------------------------------------------------------------------------- /_vendor/range-v3/include/meta/meta_fwd.hpp: -------------------------------------------------------------------------------- 1 | /// \file meta_fwd.hpp Forward declarations 2 | // 3 | // Meta library 4 | // 5 | // Copyright Eric Niebler 2014-2015 6 | // 7 | // Use, modification and distribution is subject to the 8 | // Boost Software License, Version 1.0. (See accompanying 9 | // file LICENSE_1_0.txt or copy at 10 | // http://www.boost.org/LICENSE_1_0.txt) 11 | // 12 | // Project home: https://github.com/ericniebler/meta 13 | // 14 | 15 | #ifndef META_FWD_HPP 16 | #define META_FWD_HPP 17 | 18 | #include 19 | 20 | #ifndef META_DISABLE_DEPRECATED_WARNINGS 21 | #ifdef __cpp_attribute_deprecated 22 | #define META_DEPRECATED(MSG) [[deprecated(MSG)]] 23 | #else 24 | #if defined(__clang__) || defined(__GNUC__) 25 | #define META_DEPRECATED(MSG) __attribute__((deprecated(MSG))) 26 | #elif defined(_MSC_VER) 27 | #define META_DEPRECATED(MSG) __declspec(deprecated(MSG)) 28 | #else 29 | #define META_DEPRECATED(MSG) 30 | #endif 31 | #endif 32 | #else 33 | #define META_DEPRECATED(MSG) 34 | #endif 35 | 36 | namespace meta 37 | { 38 | inline namespace v1 39 | { 40 | #ifdef __cpp_lib_integer_sequence 41 | using std::integer_sequence; 42 | #else 43 | template 44 | struct integer_sequence; 45 | #endif 46 | 47 | template 48 | struct list; 49 | 50 | template 51 | struct id; 52 | 53 | template