├── Effective_Modern_Cpp
├── Item01-template_deduction
│ ├── Item01.md
│ ├── Item01_en.md
│ ├── Makefile
│ └── code.cc
├── Item02-auto_deduction
│ ├── Item02.md
│ ├── Makefile
│ └── code.cc
├── Item03-decltype
│ ├── Item03.md
│ ├── Makefile
│ └── code.cc
├── Item04-check_deduced_type
│ ├── Item04.md
│ ├── Makefile
│ └── code.cc
├── Item05-use_auto
│ ├── Item05.md
│ ├── Makefile
│ └── code.cc
├── Item06-not_use_auto
│ ├── Item06.md
│ ├── Makefile
│ └── code.cc
├── Item07-initializer
│ ├── Item07.md
│ ├── Makefile
│ └── code.cc
├── Item08-nullptr
│ ├── Item08.md
│ ├── Makefile
│ └── code.cc
├── Item09-using_vs_typedef
│ ├── Item09.md
│ ├── Makefile
│ └── code.cc
├── Item10-scoped_enum
│ ├── Item10.md
│ ├── Makefile
│ └── code.cc
├── Item11-deleted
│ ├── Item11.md
│ ├── Makefile
│ └── code.cc
├── Item12-override
│ ├── Item12.md
│ ├── Makefile
│ └── code.cc
├── Item13-const_iterator
│ ├── Item13.md
│ ├── Makefile
│ └── find_and_insert.cc
├── Item14-noexcept
│ ├── Item14.md
│ ├── Makefile
│ └── code.cc
├── Item15-constexpr
│ ├── Item15.md
│ ├── Makefile
│ └── code.cc
├── Item16-make_const_thread_safe
│ ├── Item16.md
│ ├── Makefile
│ └── code.cc
├── Item17-autogen_member_functions
│ ├── Item17.md
│ ├── Makefile
│ ├── code.cc
│ └── default.cc
├── Item18-unique_ptr
│ ├── Item18.md
│ ├── Makefile
│ ├── code.cc
│ └── printargs.cc
├── Item19-shared_ptr
│ ├── Item19.md
│ ├── Makefile
│ ├── code.cc
│ ├── code.cc.origin
│ └── shared_ptr.png
├── Item20-weak_ptr
│ ├── Item20.md
│ ├── Makefile
│ └── code.cc
├── Item21-make_shared_make_uniqure
│ ├── Item21.md
│ ├── Makefile
│ └── code.cc
├── Item22-Pimp_Idiom
│ ├── Item22.md
│ ├── Makefile
│ ├── c++98
│ │ ├── Makefile
│ │ ├── code.cc
│ │ ├── gadget.h
│ │ ├── widget.cc
│ │ └── widget.h
│ ├── code.cc
│ ├── gadget.h
│ ├── widget.cc
│ └── widget.h
├── Item23-move_forward
│ ├── Item23.md
│ ├── Makefile
│ └── code.cc
├── Item24-universal_reference
│ ├── Item24.md
│ ├── Makefile
│ └── code.cc
├── Item25-move@rvalue_forward@universal
│ ├── Item25.md
│ ├── Makefile
│ └── code.cc
├── Item26-avoid_overload@universal
│ ├── Item26.md
│ ├── Makefile
│ └── code.cc
├── Item27-alternatives_to_overload@universal
│ ├── Item27.md
│ ├── Makefile
│ └── code.cc
├── Item28-reference_collapsing
│ ├── Item28.md
│ ├── Makefile
│ └── code.cc
├── Item29-move-failure
│ ├── Item29.md
│ ├── Makefile
│ ├── arr_move.png
│ ├── code.cc
│ └── vec_move.png
├── Item30-imperfect_forward
│ ├── Item30.md
│ ├── Makefile
│ └── code.cc
├── Item31-avoid_default_capture
│ ├── Item31.md
│ ├── Makefile
│ └── code.cc
├── Item32-use_init_capture
│ ├── Item32.md
│ ├── Makefile
│ └── code.cc
├── Item33-universal_auto_in_lambda
│ ├── Item33.md
│ ├── Makefile
│ └── code.cc
├── Item34-prefer_lambda_to_bind
│ ├── Item34.md
│ ├── Makefile
│ └── code.cc
├── Item35-prefer_task_to_thread
│ ├── Item35.md
│ ├── Makefile
│ └── code.cc
├── Item36-async_if_asynchronicity@launch@std
│ ├── Item36.md
│ ├── Makefile
│ └── code.cc
├── Item37-unjoinable
│ ├── Item37.md
│ ├── Makefile
│ └── code.cc
├── Item38-varying_thread_destructor
│ ├── Item38.md
│ ├── Makefile
│ └── code.cc
├── Item39-void_futures
│ ├── ConditionVariable.cc
│ ├── Item39.md
│ ├── Makefile
│ └── code.cc
├── Item40-atomic_volatile@std
│ ├── Item40.md
│ ├── Makefile
│ ├── code
│ └── code.cc
├── Item41-always_copy
│ ├── Item41.md
│ ├── Makefile
│ └── code.cc
├── Item42-emplace_back
│ ├── Item42.md
│ ├── Makefile
│ └── code.cc
└── README.md
├── Fluent_Python
├── ch01-data-model
│ ├── cards.py
│ └── vec.py
├── ch02-array-seq
│ ├── 2.3tuple.py
│ ├── cartesian.py
│ ├── genexps.py
│ ├── listcomps.py
│ └── my_bisect.py
├── ch03-dict-set
│ ├── StrKeyDict.py
│ ├── dialcodes.py
│ └── index.py
├── ch04-text-byte
│ ├── README.rst
│ ├── default_encodings.py
│ ├── normeq.py
│ ├── numerics_demo.py
│ ├── ramanujan.py
│ └── sanitize.py
├── ch05-1class-func
│ ├── bingocall.py
│ ├── clip.py
│ ├── factorial.py
│ ├── functor.py
│ └── tagger.py
├── ch06-dp-1class-func
│ ├── README.rst
│ ├── classic_strategy.py
│ ├── strategy_best
│ │ ├── promotions.py
│ │ └── strategy_best.py
│ └── strategy_func
│ │ ├── c++_version
│ │ ├── Makefile
│ │ └── code.cc
│ │ └── strategy_func.py
├── ch07-deco-closure
│ ├── README.rst
│ ├── average
│ │ ├── average.py
│ │ └── average_oo.py
│ ├── clockdeco
│ │ ├── clock_param
│ │ │ ├── __pycache__
│ │ │ │ └── clockdeco_param.cpython-36.pyc
│ │ │ ├── clockdeco_param.py
│ │ │ ├── clockdeco_param_demo1.py
│ │ │ └── clockdeco_param_demo2.py
│ │ ├── clockdeco
│ │ │ ├── clockdeco.py
│ │ │ ├── clockdeco_demo.py
│ │ │ ├── fibo_demo.py
│ │ │ └── fibo_demo_lru.py
│ │ └── clockdeco_cls.py
│ ├── fibo_demo.py
│ ├── fibo_demo_lru.py
│ ├── generic.py
│ ├── global_x_local.rst
│ ├── registration.py
│ ├── registration_abridged.py
│ ├── registration_param.py
│ └── strategy_best.py
├── ch09-pythonic-obj
│ ├── mem_test.py
│ └── vector2d.py
├── ch10-seq-hacking
│ ├── README.rst
│ └── vector.py
├── ch11-iface-abc
│ ├── frenchdeck_class
│ │ └── frenchdeck2.py
│ ├── tombola_class
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-36.pyc
│ │ │ ├── bingo.cpython-36.pyc
│ │ │ ├── drum.cpython-36.pyc
│ │ │ ├── lotto.cpython-36.pyc
│ │ │ ├── tombola.cpython-36.pyc
│ │ │ └── tombolist.cpython-36.pyc
│ │ ├── bingo.py
│ │ ├── drum.py
│ │ ├── lotto.py
│ │ ├── tombola.py
│ │ ├── tombola_subhook.py
│ │ └── tombolist.py
│ └── tombola_runner.py
├── ch12-inheritance
│ └── diamond.py
├── ch13-op-overloading
│ ├── bingo_addable
│ │ ├── bingo.py
│ │ ├── bingoaddable.py
│ │ └── tombola.py
│ ├── unary_plus_decimal.py
│ └── vector.py
├── ch14-it-generator
│ ├── aritprog
│ │ ├── aritprog_float_error.py
│ │ ├── aritprog_runner.py
│ │ └── class
│ │ │ ├── __pycache__
│ │ │ ├── aritprog_v0.cpython-36.pyc
│ │ │ ├── aritprog_v1.cpython-36.pyc
│ │ │ ├── aritprog_v2.cpython-36.pyc
│ │ │ └── aritprog_v3.cpython-36.pyc
│ │ │ ├── aritprog_v0.py
│ │ │ ├── aritprog_v1.py
│ │ │ ├── aritprog_v2.py
│ │ │ └── aritprog_v3.py
│ ├── isis2json
│ │ ├── README.rst
│ │ ├── cds.iso
│ │ ├── cds.mst
│ │ ├── cds1.json
│ │ ├── cds2.json
│ │ ├── isis2json.py
│ │ ├── iso2709.py
│ │ └── subfield.py
│ ├── sentence
│ │ ├── class
│ │ │ ├── __pycache__
│ │ │ │ ├── sentence_gen.cpython-36.pyc
│ │ │ │ ├── sentence_gen2.cpython-36.pyc
│ │ │ │ ├── sentence_genexp.cpython-36.pyc
│ │ │ │ ├── sentence_getitem.cpython-36.pyc
│ │ │ │ ├── sentence_iter.cpython-36.pyc
│ │ │ │ └── sentence_iter2.cpython-36.pyc
│ │ │ ├── sentence_gen.py
│ │ │ ├── sentence_gen2.py
│ │ │ ├── sentence_genexp.py
│ │ │ ├── sentence_getitem.py
│ │ │ ├── sentence_iter.py
│ │ │ └── sentence_iter2.py
│ │ └── sentence_runner.py
│ └── soapbox
│ │ ├── fibo_by_hand.py
│ │ └── yield_delegate
│ │ ├── yield_delegate_fail.py
│ │ └── yield_delegate_fix.py
├── ch15-context-mngr
│ ├── contextlib
│ │ └── mirror_gen_exc.py
│ └── mirror.py
├── ch16-coroutine
│ ├── c_impl
│ │ ├── Makefile
│ │ ├── coro.cc
│ │ ├── coro.h
│ │ └── main.cc
│ ├── coro_except
│ │ ├── coro_exc_demo.py
│ │ └── coro_finally_demo.py
│ ├── coroaverager
│ │ ├── coroaverager1-prime
│ │ │ ├── coroaverager1.py
│ │ │ └── coroutil.py
│ │ └── coroaverager3.py
│ ├── simple.py
│ ├── taxi
│ │ ├── taxi_sim.py
│ │ ├── taxi_sim0.py
│ │ └── taxi_sim_delay.py
│ └── yield_from_expansion
│ │ ├── yield_from_expansion.py
│ │ └── yield_from_expansion_simplified.py
├── ch17-futures
│ ├── demo_executor_map.py
│ ├── flags
│ │ ├── __pycache__
│ │ │ └── flags.cpython-36.pyc
│ │ ├── downloads
│ │ │ ├── bd.gif
│ │ │ ├── br.gif
│ │ │ ├── cd.gif
│ │ │ ├── cn.gif
│ │ │ ├── de.gif
│ │ │ ├── eg.gif
│ │ │ ├── et.gif
│ │ │ ├── fr.gif
│ │ │ ├── id.gif
│ │ │ ├── in.gif
│ │ │ ├── ir.gif
│ │ │ ├── jp.gif
│ │ │ ├── mx.gif
│ │ │ ├── ng.gif
│ │ │ ├── ph.gif
│ │ │ ├── pk.gif
│ │ │ ├── ru.gif
│ │ │ ├── tr.gif
│ │ │ ├── us.gif
│ │ │ └── vn.gif
│ │ ├── flags.py
│ │ ├── flags_threadpool.py
│ │ └── flags_threadpool_ac.py
│ ├── flags2
│ │ ├── __pycache__
│ │ │ ├── flags2_common.cpython-36.pyc
│ │ │ └── flags2_sequential.cpython-36.pyc
│ │ ├── downloads
│ │ │ ├── bd.gif
│ │ │ ├── br.gif
│ │ │ ├── cd.gif
│ │ │ ├── cn.gif
│ │ │ ├── de.gif
│ │ │ ├── eg.gif
│ │ │ ├── et.gif
│ │ │ ├── fr.gif
│ │ │ ├── id.gif
│ │ │ ├── in.gif
│ │ │ ├── ir.gif
│ │ │ ├── jp.gif
│ │ │ ├── mx.gif
│ │ │ ├── ng.gif
│ │ │ ├── ph.gif
│ │ │ ├── pk.gif
│ │ │ ├── ru.gif
│ │ │ ├── tr.gif
│ │ │ ├── us.gif
│ │ │ └── vn.gif
│ │ ├── flags2_asyncio_executor.py
│ │ ├── flags2_common.py
│ │ ├── flags2_sequential.py
│ │ └── flags2_threadpool.py
│ └── flags3
│ │ └── flags3_threadpool.py
├── ch18-asyncio
│ ├── charfinder
│ │ ├── charfinder.py
│ │ ├── http_charfinder.html
│ │ ├── http_charfinder.py
│ │ ├── requirements.txt
│ │ ├── tcp_charfinder.py
│ │ └── test_charfinder.py
│ ├── flags
│ │ ├── downloads
│ │ │ ├── bd.gif
│ │ │ ├── br.gif
│ │ │ ├── cd.gif
│ │ │ ├── cn.gif
│ │ │ ├── de.gif
│ │ │ ├── eg.gif
│ │ │ ├── et.gif
│ │ │ ├── fr.gif
│ │ │ ├── id.gif
│ │ │ ├── in.gif
│ │ │ ├── ir.gif
│ │ │ ├── jp.gif
│ │ │ ├── mx.gif
│ │ │ ├── ng.gif
│ │ │ ├── ph.gif
│ │ │ ├── pk.gif
│ │ │ ├── ru.gif
│ │ │ ├── tr.gif
│ │ │ ├── us.gif
│ │ │ └── vn.gif
│ │ ├── flags2_asyncio.py
│ │ ├── flags2_asyncio_executor.py
│ │ ├── flags_asyncio.py
│ │ └── imported
│ │ │ ├── flags.py
│ │ │ └── flags2_common.py
│ └── spinner
│ │ ├── spinner_asyncio.py
│ │ ├── spinner_curio.py
│ │ └── spinner_thread.py
├── ch18b-async-await
│ ├── README.rst
│ ├── charfinder
│ │ ├── __pycache__
│ │ │ └── charfinder.cpython-36.pyc
│ │ ├── charfinder.py
│ │ ├── http_charfinder.html
│ │ ├── http_charfinder.py
│ │ ├── tcp_charfinder.py
│ │ └── test_charfinder.py
│ ├── flags
│ │ ├── flags2_await.py
│ │ ├── flags_await.py
│ │ └── imported
│ │ │ ├── __pycache__
│ │ │ ├── flags.cpython-36.pyc
│ │ │ └── flags2_common.cpython-36.pyc
│ │ │ ├── flags.py
│ │ │ └── flags2_common.py
│ └── spinner
│ │ ├── spinner_asyncio.py
│ │ ├── spinner_await.py
│ │ ├── spinner_curio.py
│ │ └── spinner_thread.py
├── ch19-dyn-attr-prop
│ ├── blackknight.py
│ ├── bulkfood
│ │ ├── bulkfood_v1.py
│ │ ├── bulkfood_v2.py
│ │ ├── bulkfood_v2b.py
│ │ └── bulkfood_v2prop.py
│ ├── doc_property.py
│ ├── oscon
│ │ ├── __pycache__
│ │ │ └── osconfeed.cpython-36.pyc
│ │ ├── data
│ │ │ └── osconfeed.json
│ │ ├── demo_schedule2.py
│ │ ├── explore2.py
│ │ ├── osconfeed.py
│ │ ├── schedule2.py
│ │ ├── test_schedule1.py
│ │ └── test_schedule2.py
│ └── pseudo_construction.py
├── ch20-descriptor
│ ├── bulkfood
│ │ ├── bulkfood_v3.py
│ │ ├── bulkfood_v4.py
│ │ ├── bulkfood_v4b.py
│ │ ├── bulkfood_v4c.py
│ │ ├── bulkfood_v4prop.py
│ │ ├── bulkfood_v5.py
│ │ ├── bulkfood_v5_check.py
│ │ ├── model_v4c.py
│ │ ├── model_v5.py
│ │ └── model_v5_check.py
│ ├── descriptorkinds.py
│ ├── descriptorkinds_dump.py
│ └── method_is_descriptor.py
└── ch21-class-metaprog
│ ├── README.rst
│ ├── bulkfood
│ ├── bulkfood_v6.py
│ ├── bulkfood_v7.py
│ ├── bulkfood_v8.py
│ ├── model_v6.py
│ ├── model_v7.py
│ └── model_v8.py
│ ├── evalsupport.py
│ ├── evaltime.py
│ ├── evaltime_meta.py
│ └── factories.py
├── In-depth_C++11
├── ch01-moderner_and_simpler
│ ├── .cc
│ ├── 1-01_auto.cc
│ ├── 1-02_auto.cc
│ ├── 1-03_decltype.cc
│ ├── 1-04_decltype.cc
│ ├── 1-05_template.cc
│ ├── 1-06_》.cc
│ ├── 1-07_init.cc
│ ├── 1-08_init.cc
│ ├── 1-09_init.cc
│ ├── 1-10_init_narrow.cc
│ ├── 1-11_1-15_for_range
│ │ ├── Range.hpp
│ │ └── Test.cc
│ ├── 1-16_functor.cc
│ ├── 1-17_std_function.cc
│ ├── 1-19.cc
│ ├── 1-20.cc
│ ├── 1-21.cc
│ ├── 1-22.cc
│ ├── 1-23.cc
│ ├── 1-24.cc
│ └── Makefile
├── ch02-rvalue
│ ├── 2-1.cc
│ ├── 2-2.cc
│ ├── 2-3.cc
│ ├── 2-4.cc
│ ├── 2-5.cc
│ ├── 2-6.cc
│ └── Makefile
├── ch03-type_traits_and_vargs
│ ├── 3-1.cc
│ ├── 3-10
│ │ ├── 3-10.sln
│ │ ├── 3-10.v12.suo
│ │ └── 3-10
│ │ │ ├── 3-10.vcxproj
│ │ │ ├── 3-10.vcxproj.filters
│ │ │ ├── DllParser.hpp
│ │ │ ├── MyDLL.dll
│ │ │ └── Test.cpp
│ ├── 3-12
│ │ ├── 3-12.sln
│ │ ├── 3-12.v12.suo
│ │ └── 3-12
│ │ │ ├── 3-12.vcxproj
│ │ │ ├── 3-12.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-13
│ │ ├── 3-13.sln
│ │ ├── 3-13.v12.suo
│ │ └── 3-13
│ │ │ ├── 3-13.vcxproj
│ │ │ ├── 3-13.vcxproj.filters
│ │ │ ├── Any.hpp
│ │ │ └── 源.cpp
│ ├── 3-14
│ │ ├── 3-14.sln
│ │ ├── 3-14.v12.suo
│ │ └── 3-14
│ │ │ ├── 3-14.vcxproj
│ │ │ ├── 3-14.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-15
│ │ ├── 3-15.sln
│ │ ├── 3-15.v12.suo
│ │ └── 3-15
│ │ │ ├── 3-15.vcxproj
│ │ │ ├── 3-15.vcxproj.filters
│ │ │ ├── Test.cpp
│ │ │ └── Variant.hpp
│ ├── 3-17
│ │ ├── 3-17.sln
│ │ ├── 3-17.v12.suo
│ │ └── 3-17
│ │ │ ├── 3-17.vcxproj
│ │ │ ├── 3-17.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-18
│ │ ├── 3-18.sln
│ │ ├── 3-18.v12.suo
│ │ └── 3-18
│ │ │ ├── 3-18.vcxproj
│ │ │ ├── 3-18.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-19
│ │ ├── 3-19.sln
│ │ ├── 3-19.v11.suo
│ │ ├── 3-19.v12.suo
│ │ └── 3-19
│ │ │ ├── 3-19.vcxproj
│ │ │ ├── 3-19.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-2.cc
│ ├── 3-20
│ │ ├── 3-20.sln
│ │ ├── 3-20.v12.suo
│ │ └── 3-20
│ │ │ ├── 3-20.vcxproj
│ │ │ ├── 3-20.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-21
│ │ ├── 3-21.sln
│ │ ├── 3-21.v12.suo
│ │ └── 3-21
│ │ │ ├── 3-21.vcxproj
│ │ │ ├── 3-21.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-22
│ │ ├── 3-22.sln
│ │ ├── 3-22.v12.suo
│ │ └── 3-22
│ │ │ ├── 3-22.vcxproj
│ │ │ ├── 3-22.vcxproj.filters
│ │ │ ├── Test.cpp
│ │ │ ├── TpForeach.hpp
│ │ │ └── TpIndexs.hpp
│ ├── 3-23
│ │ ├── 3-23.sln
│ │ ├── 3-23.v12.suo
│ │ └── 3-23
│ │ │ ├── 3-23.vcxproj
│ │ │ ├── 3-23.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-24
│ │ ├── 3-24.sln
│ │ ├── 3-24.v12.suo
│ │ └── 3-24
│ │ │ ├── 3-24.vcxproj
│ │ │ ├── 3-24.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-25
│ │ ├── 3-25.sln
│ │ ├── 3-25.v12.suo
│ │ └── 3-25
│ │ │ ├── 3-25.vcxproj
│ │ │ ├── 3-25.vcxproj.filters
│ │ │ ├── Test.cpp
│ │ │ └── TpZip.hpp
│ ├── 3-3
│ │ ├── 3-3.sln
│ │ ├── 3-3.v12.suo
│ │ └── 3-3
│ │ │ ├── 3-3.vcxproj
│ │ │ ├── 3-3.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-4
│ │ ├── 3-4.sln
│ │ ├── 3-4.v12.suo
│ │ └── 3-4
│ │ │ ├── 3-4.vcxproj
│ │ │ ├── 3-4.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 3-5
│ │ ├── 3-5.sln
│ │ ├── 3-5.v12.suo
│ │ └── 3-5
│ │ │ ├── 3-5.vcxproj
│ │ │ ├── 3-5.vcxproj.filters
│ │ │ ├── Test.cpp
│ │ │ └── optional.hpp
│ ├── 3-7~3-8
│ │ ├── 3-7~3-8.sln
│ │ ├── 3-7~3-8.v12.suo
│ │ └── 3-7~3-8
│ │ │ ├── 3-7~3-8.vcxproj
│ │ │ ├── 3-7~3-8.vcxproj.filters
│ │ │ ├── Lazy.hpp
│ │ │ └── Test.cpp
│ ├── 3-9
│ │ ├── 3-9.sln
│ │ ├── 3-9.v12.suo
│ │ └── 3-9
│ │ │ ├── 3-9.vcxproj
│ │ │ ├── 3-9.vcxproj.filters
│ │ │ ├── MyDLL.dll
│ │ │ ├── MyDLL.h
│ │ │ ├── MyDLL.lib
│ │ │ └── Test.cpp
│ ├── 3.16
│ │ ├── ScopeGuard.h
│ │ └── Test.cc
│ ├── Makefile
│ └── enable_if.cc
├── ch04-smart-pointer
│ ├── 4-1
│ ├── 4-1.cc
│ └── Makefile
├── ch05-thread
│ ├── 5-1
│ │ ├── 5-1.sln
│ │ ├── 5-1.v12.suo
│ │ └── 5-1
│ │ │ ├── 5-1.vcxproj
│ │ │ ├── 5-1.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 5-10
│ │ ├── 5-10.sln
│ │ ├── 5-10.v12.suo
│ │ └── 5-10
│ │ │ ├── 5-10.vcxproj
│ │ │ ├── 5-10.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 5-2
│ │ ├── 5-2.sln
│ │ ├── 5-2.v12.suo
│ │ └── 5-2
│ │ │ ├── 5-2.vcxproj
│ │ │ ├── 5-2.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 5-3
│ │ ├── 5-3.sln
│ │ ├── 5-3.v12.suo
│ │ └── 5-3
│ │ │ ├── 5-3.vcxproj
│ │ │ ├── 5-3.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 5-4
│ │ ├── 5-4.sln
│ │ ├── 5-4.v12.suo
│ │ └── 5-4
│ │ │ ├── 5-4.vcxproj
│ │ │ ├── 5-4.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 5-5
│ │ ├── 5-5.sln
│ │ ├── 5-5.v12.suo
│ │ └── 5-5
│ │ │ ├── 5-5.vcxproj
│ │ │ ├── 5-5.vcxproj.filters
│ │ │ ├── SyncQueue.hpp
│ │ │ └── Test.cpp
│ ├── 5-6
│ │ ├── 5-6.sln
│ │ ├── 5-6.v12.suo
│ │ └── 5-6
│ │ │ ├── 5-6.vcxproj
│ │ │ ├── 5-6.vcxproj.filters
│ │ │ ├── SimpleSyncQueue.hpp
│ │ │ └── Test.cpp
│ ├── 5-7
│ │ ├── 5-7.sln
│ │ ├── 5-7.v12.suo
│ │ └── 5-7
│ │ │ ├── 5-7.vcxproj
│ │ │ ├── 5-7.vcxproj.filters
│ │ │ └── Test.cpp
│ ├── 5-8
│ │ ├── 5-8.sln
│ │ ├── 5-8.v12.suo
│ │ └── 5-8
│ │ │ ├── 5-8.vcxproj
│ │ │ ├── 5-8.vcxproj.filters
│ │ │ └── Test.cpp
│ └── 5-9
│ │ ├── 5-9.sln
│ │ ├── 5-9.v12.suo
│ │ └── 5-9
│ │ ├── 5-9.vcxproj
│ │ ├── 5-9.vcxproj.filters
│ │ └── Test.cpp
├── ch06-chrono_and_convert
│ ├── 6-1
│ ├── 6-2
│ ├── 6-2.cc
│ ├── 6-3.cc
│ ├── 6.1
│ │ ├── Test.cc
│ │ ├── Timer.h
│ │ └── Timer.hpp
│ └── Makefile
└── ch08-Pattern
│ ├── 8-3
│ ├── 8-3.cc
│ ├── 8-5
│ ├── 8-5.cc
│ ├── Command.hpp
│ ├── Makefile
│ ├── NonCopyable.hpp
│ ├── ObjectPool.hpp
│ ├── Observer.hpp
│ ├── Singleton.h
│ └── Visitor.hpp
├── Muduo_ChenShuo
├── Makefile
├── ch01.cc
├── ch02.cc
├── ch05.cc
├── ch06_sudoku
│ ├── CMakeLists.txt
│ ├── README
│ ├── batch.cc
│ ├── build.sh
│ ├── diff_basic_multiloop.diff
│ ├── diff_basic_threadpool.diff
│ ├── diff_hybrid_prod.diff
│ ├── loadtest.cc
│ ├── percentile.h
│ ├── pipeline.cc
│ ├── req.txt
│ ├── server_basic.cc
│ ├── server_hybrid.cc
│ ├── server_multiloop.cc
│ ├── server_prod.cc
│ ├── server_threadpool.cc
│ ├── stat.h
│ ├── stat_unittest.cc
│ ├── sudoku.cc
│ └── sudoku.h
└── ch08_reactor
│ ├── Makefile
│ ├── README
│ ├── mkdiff.sh
│ ├── s00_EventLoop
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── Makefile
│ ├── test1.cc
│ └── test2.cc
│ ├── s01_timerfd
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ └── test3.cc
│ ├── s02_TimerQueue
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ └── test4.cc
│ ├── s03_runInLoop
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ ├── test5.cc
│ └── test6.cc
│ ├── s04_Acceptor
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ └── test7.cc
│ ├── s05_TcpConnection
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ └── test8.cc
│ ├── s06_TcpConnection
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ └── test8.cc
│ ├── s07_Buffer
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Buffer.cc
│ ├── Buffer.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ ├── test3.cc
│ └── test8.cc
│ ├── s08_send
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Buffer.cc
│ ├── Buffer.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ ├── test10.cc
│ └── test9.cc
│ ├── s09_SIGPIPE
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Buffer.cc
│ ├── Buffer.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ ├── test10.cc
│ ├── test11.cc
│ └── test9.cc
│ ├── s10_multithread
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Buffer.cc
│ ├── Buffer.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── EventLoopThreadPool.cc
│ ├── EventLoopThreadPool.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ ├── test10.cc
│ ├── test11.cc
│ ├── test8.cc
│ └── test9.cc
│ ├── s11_Connector
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Buffer.cc
│ ├── Buffer.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── Connector.cc
│ ├── Connector.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── EventLoopThreadPool.cc
│ ├── EventLoopThreadPool.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ ├── test12.cc
│ └── test4.cc
│ ├── s12_TcpClient
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Buffer.cc
│ ├── Buffer.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── Connector.cc
│ ├── Connector.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── EventLoopThreadPool.cc
│ ├── EventLoopThreadPool.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpClient.cc
│ ├── TcpClient.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ └── test13.cc
│ └── s13_epoll
│ ├── Acceptor.cc
│ ├── Acceptor.h
│ ├── Buffer.cc
│ ├── Buffer.h
│ ├── Callbacks.h
│ ├── Channel.cc
│ ├── Channel.h
│ ├── Connector.cc
│ ├── Connector.h
│ ├── EPoller.cc
│ ├── EPoller.h
│ ├── EventLoop.cc
│ ├── EventLoop.h
│ ├── EventLoopThread.cc
│ ├── EventLoopThread.h
│ ├── EventLoopThreadPool.cc
│ ├── EventLoopThreadPool.h
│ ├── InetAddress.cc
│ ├── InetAddress.h
│ ├── Makefile
│ ├── Poller.cc
│ ├── Poller.h
│ ├── Socket.cc
│ ├── Socket.h
│ ├── SocketsOps.cc
│ ├── SocketsOps.h
│ ├── TcpClient.cc
│ ├── TcpClient.h
│ ├── TcpConnection.cc
│ ├── TcpConnection.h
│ ├── TcpServer.cc
│ ├── TcpServer.h
│ ├── Timer.cc
│ ├── Timer.h
│ ├── TimerId.h
│ ├── TimerQueue.cc
│ ├── TimerQueue.h
│ ├── test1.cc
│ ├── test10.cc
│ ├── test11.cc
│ ├── test12.cc
│ ├── test13.cc
│ ├── test2.cc
│ ├── test3.cc
│ ├── test4.cc
│ ├── test5.cc
│ ├── test6.cc
│ ├── test7.cc
│ ├── test8.cc
│ └── test9.cc
├── README.md
└── Using_STL
├── .vscode
├── launch.json
├── settings.json
└── tasks.json
├── Checkout
├── Checkout_object
│ ├── Checkout.h
│ ├── Customer.h
│ └── Ex3_02.cpp
├── Checkout_up
│ ├── Checkout.h
│ ├── Customer.h
│ ├── Makefile
│ └── code.cc
├── checkout.h
├── customer.h
└── main.cc
├── Makefile
├── ch01.cc
├── ch02.cc
├── ch06.cc
├── ch07.cc
├── ch09.cc
├── ch09_cin.cc
├── ch10.cc
├── ch10_gaussion.cc
├── cin_recovery.cc
└── data
├── Renewables_vs_kwh_cost.txt
├── dictionary.txt
├── dictionary_copy.txt
├── fibonacci.txt
└── temperatures.txt
/Effective_Modern_Cpp/Item01-template_deduction/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 | code: CXXFLAGS += -Wall
17 | code: code.cc
18 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item02-auto_deduction/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item03-decltype/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item04-check_deduced_type/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item04-check_deduced_type/code.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | template
6 | void f(const T& param)
7 | {
8 | using boost::typeindex::type_id_with_cvr;
9 |
10 | // show T
11 | std::cout << "T = "
12 | << type_id_with_cvr().pretty_name()
13 | << '\n';
14 | // show param's type
15 | std::cout << "param = "
16 | << type_id_with_cvr().pretty_name()
17 | << '\n';
18 | //…
19 | }
20 |
21 | struct Widget{};
22 | std::vector vec;
23 | std::vector createVec()
24 | {
25 | const Widget w;
26 | vec.push_back(w);
27 |
28 | return vec;
29 | }
30 |
31 | int main(void)
32 | {
33 | const auto vw = createVec();
34 |
35 | if(!vw.empty()){
36 | f(&vw[0]);
37 | //...
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item05-use_auto/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item06-not_use_auto/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item07-initializer/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: code.cc
18 |
19 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item08-nullptr/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | #code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item09-using_vs_typedef/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | #code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item10-scoped_enum/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 | #code: CXXFLAGS += -Wall
17 | code: code.cc
18 |
19 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item11-deleted/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | #code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item12-override/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 | code: CXXFLAGS += -Wall
17 | code: code.cc
18 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item13-const_iterator/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = find_and_insert
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 | #find_and_insert: CXXFLAGS += -Wall
17 | find_and_insert: find_and_insert.cc
18 |
19 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item14-noexcept/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item15-constexpr/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 | #code: CXXFLAGS += -Wall
17 | code: code.cc
18 |
19 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item16-make_const_thread_safe/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item17-autogen_member_functions/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code default
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 | default: default.cc
21 |
22 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item18-unique_ptr/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code printargs
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 | printargs: printargs.cc
21 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item19-shared_ptr/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item19-shared_ptr/shared_ptr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Effective_Modern_Cpp/Item19-shared_ptr/shared_ptr.png
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item20-weak_ptr/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item21-make_shared_make_uniqure/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc widget.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/c++98/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread -lmuduo_net -lmuduo_base
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc widget.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/c++98/code.cc:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | int main(void)
4 | {
5 | Widget w;
6 |
7 | return 0;
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/c++98/gadget.h:
--------------------------------------------------------------------------------
1 | //自定义类型的定义
2 | typedef int Gadget;
3 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/c++98/widget.cc:
--------------------------------------------------------------------------------
1 | #include "widget.h" //在实现文件"widget.cpp"中
2 | #include "gadget.h"
3 | #include
4 | #include
5 |
6 | struct Widget::Impl{ // 带有之前在Widget中的数据成员的
7 | std::string name; // Widget::Impl的定义
8 | std::vector data;
9 | Gadget g1, g2, g3;
10 | };
11 |
12 | Widget::Widget() // 分配Widget对象的数据成员
13 | : pImpl(new Impl)
14 | {}
15 |
16 | Widget::~Widget() // 归还这个对象的数据成员
17 | { delete pImpl; }
18 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/c++98/widget.h:
--------------------------------------------------------------------------------
1 | class Widget{ // 还是在头文件"widget.h"中
2 | public:
3 | Widget();
4 | ~Widget(); // 看下面的内容可以得知析构函数是需要的
5 | //...
6 |
7 | private:
8 | struct Impl; // 声明一个要实现的结构
9 | Impl *pImpl; // 并用指针指向它
10 | };
11 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/code.cc:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | int main(void)
4 | {
5 |
6 | Widget w; //如果析构函数~Widget()不能实现申明和定义分离,则报错
7 |
8 | return 0;
9 | }
10 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/gadget.h:
--------------------------------------------------------------------------------
1 | //自定义类型的定义
2 | typedef int Gadget;
3 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/widget.cc:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 | #include "gadget.h"
3 | #include
4 | #include
5 |
6 | struct Widget::Impl { // 和以前一样
7 | std::string name;
8 | std::vector data;
9 | Gadget g1, g2, g3;
10 | };
11 |
12 | //Widget::~Widget(){} //显式地定义析构函数, 申明和定义分离
13 | Widget::~Widget() = default; //效果同上
14 |
15 | Widget::Widget() //通过std::make_unique来创建一个std::unique_ptr
16 | : pImpl(std::make_unique())
17 | {}
18 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item22-Pimp_Idiom/widget.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | //unique_ptr.h:76:22: error: invalid application of ‘sizeof’ to incomplete type ‘Widget::Impl’
4 | //error产生的根源: “编译器产生的”析构函数,在析构之前,需要销毁被pImpl指向的对象,但是在Widget的头文件中,pImpl指向一个不完整类型。
5 | //error产生的根源: “编译器产生的” operator move 在重新赋值前,需要销毁被pImpl指向的对象,但是在Widget的头文件中,pImpl指向一个不完整类型。
6 | class Widget{
7 | public:
8 | Widget();
9 | //...
10 | ~Widget(); // 为了消除siezof error,避免内联, 声明和实现析构函数必须分离, 则可以防止static_assert出错
11 | //~Widget(){} //声明+定义~Widget()依然报sizeof error错.
12 |
13 | private:
14 | struct Impl; //前置申明
15 | std::unique_ptr pImpl;// 使用智能指针来替换原始指针
16 | };
17 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item23-move_forward/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item24-universal_reference/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item25-move@rvalue_forward@universal/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item26-avoid_overload@universal/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item27-alternatives_to_overload@universal/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item28-reference_collapsing/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item29-move-failure/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item29-move-failure/arr_move.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Effective_Modern_Cpp/Item29-move-failure/arr_move.png
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item29-move-failure/code.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(void)
4 | {
5 |
6 | std::vector vw1;
7 | // put data into vw1
8 |
9 | //...
10 |
11 | // move vw1 into vw2. Runs in
12 | // constant time. Only ptrs
13 | // in vw1 and vw2 are modified
14 | auto vw2 = std::move(vw1);
15 |
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item29-move-failure/vec_move.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Effective_Modern_Cpp/Item29-move-failure/vec_move.png
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item30-imperfect_forward/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item31-avoid_default_capture/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item32-use_init_capture/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item33-universal_auto_in_lambda/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item33-universal_auto_in_lambda/code.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | void func(int x)
5 | {
6 | std::cout<(param)));
17 | };
18 | f(2);
19 |
20 | return 0;
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item34-prefer_lambda_to_bind/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item35-prefer_task_to_thread/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item35-prefer_task_to_thread/code.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int doAsyncWork()
6 | {
7 | for(int i=0; i<30000; i++)
8 | for(int i=0; i<90000; i++)
9 | ;
10 |
11 | std::cout << "do AsyncWork..." << std::endl;
12 | return 9;
13 | }
14 |
15 | int main(void)
16 | {
17 | std::thread t(doAsyncWork);
18 | t.join();
19 |
20 | //std::future holds a shared state
21 | //std::async allow us to run the code asynchronously.
22 | auto fut = std::async(doAsyncWork); // fut for future
23 | // onus of thread mgmt is
24 | // on implements of
25 | // the STL
26 | int ret=fut.get();
27 | std::cout << "ret = " << ret << std::endl;
28 |
29 |
30 |
31 | return 0;
32 | }
33 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item36-async_if_asynchronicity@launch@std/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item37-unjoinable/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item38-varying_thread_destructor/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item39-void_futures/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code ConditionVariable
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 | ConditionVariable: ConditionVariable.cc
21 |
22 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item40-atomic_volatile@std/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item40-atomic_volatile@std/code:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Effective_Modern_Cpp/Item40-atomic_volatile@std/code
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item41-always_copy/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/Item42-emplace_back/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
20 |
--------------------------------------------------------------------------------
/Effective_Modern_Cpp/README.md:
--------------------------------------------------------------------------------
1 | # Effective_Modern_Cpp
2 | <> Chinese version and source code
3 |
4 | in every dir (corresponding to every chaptor)
5 | Use method:
6 | ```
7 | $ make
8 | $ cgdb code
9 | ```
10 |
11 |
--------------------------------------------------------------------------------
/Fluent_Python/ch01-data-model/vec.py:
--------------------------------------------------------------------------------
1 | from math import hypot
2 |
3 | class Vector:
4 | def __init__(self, x=0, y=0):
5 | self.x = x;
6 | self.y = y;
7 | def __repr__(self):
8 | #return 'Vector(%r, %r)' %(self.x, self.y)
9 | return f'Vector({self.x}, {self.y})'
10 | def __abs__(self):
11 | return hypot(self.x, self.y)
12 | def __add__(self, other):
13 | x = self.x + other.x
14 | y = self.y + other.y
15 | return Vector(x, y)
16 | def __mul__(self, scalar):
17 | return Vector(self.x*scalar, self.y*scalar)
18 | def __rmul__(self, scalar):
19 | return Vector(self.x*scalar, self.y*scalar)
20 |
21 | v1=Vector(1,2)
22 | v2 = Vector(3,4)
23 | print(v1+v2)
24 | print(v1*3)
25 | print(4*v1)
--------------------------------------------------------------------------------
/Fluent_Python/ch02-array-seq/cartesian.py:
--------------------------------------------------------------------------------
1 | colors = ['black', 'white']
2 | sizes = ['S', 'M', 'L']
3 | tshirts = [(color, size) for color in colors for size in sizes]
4 | print(tshirts)
5 |
6 | print('-------')
7 | for color in colors:
8 | for size in sizes:
9 | print((color, size))
10 |
11 | print('-------')
12 | tshirts = [(color,size) for size in sizes for color in colors]
13 | print(tshirts)
14 |
--------------------------------------------------------------------------------
/Fluent_Python/ch02-array-seq/genexps.py:
--------------------------------------------------------------------------------
1 | symbols='A中国人'
2 | t=tuple(ord(symbol) for symbol in symbols)
3 | print(t)
4 |
5 | print('---------')
6 | import array
7 | a = array.array('I', (ord(symbol) for symbol in symbols))
8 | print(a)
9 |
10 |
--------------------------------------------------------------------------------
/Fluent_Python/ch03-dict-set/dialcodes.py:
--------------------------------------------------------------------------------
1 | # BEGIN DIALCODES
2 | # dial codes of the top 10 most populous countries
3 | DIAL_CODES = [
4 | (86, 'China'),
5 | (91, 'India'),
6 | (1, 'United STates'),
7 | (62, 'Indonesia'),
8 | (55, 'Brazil'),
9 | (92, 'Pakistan'),
10 | (880, 'Bangladesh'),
11 | (234, 'Nigeria'),
12 | (7, 'Russia'),
13 | (81, 'Japan'),
14 | ]
15 | d1 = dict(DIAL_CODES) # <1>
16 | print('d1:', d1.keys()) # 打印原始的key列表
17 |
18 | d2 = dict(sorted(DIAL_CODES)) # <2>
19 | print('d2:', d2.keys()) # 打印按照key排序的key列表
20 |
21 | # lambda 参数列表 : 表达式
22 | d3 = dict(sorted(DIAL_CODES, key=lambda x:x[1])) # <3>
23 | print('d3:', d3.keys()) # 打印按照value排序的key列表
24 |
25 | # 用冒号:分割dict的key和value
26 | country_code = { country:code for code,country in DIAL_CODES }
27 | print(country_code)
28 |
29 | upper = { code:country.upper() for country,code in country_code.items() if code < 66 }
30 | print(upper)
31 |
--------------------------------------------------------------------------------
/Fluent_Python/ch04-text-byte/README.rst:
--------------------------------------------------------------------------------
1 | Sample code for Chapter 4 - "Text and bytes"
2 |
3 | From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
4 | http://shop.oreilly.com/product/0636920032519.do
5 |
--------------------------------------------------------------------------------
/Fluent_Python/ch04-text-byte/default_encodings.py:
--------------------------------------------------------------------------------
1 | import sys, locale
2 |
3 | expressions = """
4 | locale.getpreferredencoding()
5 | type(my_file)
6 | my_file.encoding
7 | sys.stdout.isatty()
8 | sys.stdout.encoding
9 | sys.stdin.isatty()
10 | sys.stdin.encoding
11 | sys.stderr.isatty()
12 | sys.stderr.encoding
13 | sys.getdefaultencoding()
14 | sys.getfilesystemencoding()
15 | """
16 |
17 | my_file = open('dummy', 'w')
18 |
19 | for expression in expressions.split():
20 | value = eval(expression)
21 | print(expression.rjust(30), '->', repr(value))
22 |
--------------------------------------------------------------------------------
/Fluent_Python/ch04-text-byte/numerics_demo.py:
--------------------------------------------------------------------------------
1 | # BEGIN NUMERICS_DEMO
2 | import unicodedata
3 | import re
4 |
5 | re_digit = re.compile(r'\d')
6 |
7 | sample = '1\xbc\xb2\u0969\u136b\u216b\u2466\u2480\u3285'
8 | sample2= '1\ubcb2\u0969\u136b\u216b\u2466\u2480\u3285'
9 |
10 | def print_str(sample):
11 | for char in sample:
12 | print('U+%04x' % ord(char), # <1>
13 | char.center(6), # <2>
14 | 're_dig' if re_digit.match(char) else '-', # <3> 是正则中的数字吗?
15 | 'isdig' if char.isdigit() else '-', # <4> 是数字吗?
16 | 'isnum' if char.isnumeric() else '-', # <5> 是数值吗?
17 | format(unicodedata.numeric(char), '5.2f'), # <6> 更多字符类型信息
18 | unicodedata.name(char), # <7> 更多字符类型信息
19 | sep='\t')
20 |
21 | print_str(sample)
22 | print_str(sample2)
23 |
24 | # END NUMERICS_DEMO
25 |
--------------------------------------------------------------------------------
/Fluent_Python/ch04-text-byte/ramanujan.py:
--------------------------------------------------------------------------------
1 | # BEGIN RE_DEMO
2 | import re
3 |
4 | re_numbers_str = re.compile(r'\d+') # <1>
5 | re_words_str = re.compile(r'\w+')
6 | re_numbers_bytes = re.compile(rb'\d+') # <2>
7 | re_words_bytes = re.compile(rb'\w+')
8 |
9 | text_str = ("Ramanujan saw \u0be7\u0bed\u0be8\u0bef" # <3>
10 | " as 1729 = 1³ + 12³ = 9³ + 10³.") # <4>
11 |
12 | text_bytes = text_str.encode('utf_8') # <5>
13 |
14 | print('Text', repr(text_str), sep='\n ')
15 | print('Numbers')
16 | print(' str :', re_numbers_str.findall(text_str)) # <6>
17 | print(' bytes:', re_numbers_bytes.findall(text_bytes)) # <7>
18 | print('Words')
19 | print(' str :', re_words_str.findall(text_str)) # <8>
20 | print(' bytes:', re_words_bytes.findall(text_bytes)) # <9>
21 | # END RE_DEMO
22 |
--------------------------------------------------------------------------------
/Fluent_Python/ch05-1class-func/bingocall.py:
--------------------------------------------------------------------------------
1 |
2 | # BEGIN BINGO
3 |
4 | import random
5 |
6 | class BingoCage:
7 |
8 | def __init__(self, items):
9 | self._items = list(items) # <1>
10 | random.shuffle(self._items) # <2>
11 |
12 | def pick(self): # <3>
13 | try:
14 | return self._items.pop()
15 | except IndexError:
16 | raise LookupError('pick from empty BingoCage') # <4>
17 |
18 | def __call__(self): # <5>
19 | return self.pick()
20 |
21 | bingo = BingoCage(range(3))
22 |
23 | print(bingo.pick()) # 0
24 | print(bingo()) # 2
25 | print(callable(bingo)) # True
26 | print(callable(bingo())) # False
27 | print(callable(BingoCage)) # True
28 | print(callable(BingoCage( (1, 2, 4) ))) # True
29 |
30 |
31 |
32 | # END BINGO
33 |
--------------------------------------------------------------------------------
/Fluent_Python/ch05-1class-func/factorial.py:
--------------------------------------------------------------------------------
1 | def factorial(n):
2 | ''' returns n! '''
3 | return 1 if n<2 else n*factorial(n-1)
4 |
5 | print(factorial(42))
6 | print(factorial.__doc__)
7 | print(type(factorial))
8 |
9 |
10 | fact = factorial
11 | print(fact)
12 | print(fact(5))
13 | print(map(factorial, range(11)))
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Fluent_Python/ch05-1class-func/functor.py:
--------------------------------------------------------------------------------
1 | fruits = [ 'strawberry', 'fig', 'apple', 'cherry', 'raspberry', 'banana']
2 | print(sorted(fruits, key=len))
3 |
4 | def reverse(word):
5 | return word[::-1]
6 |
7 | print(reverse('testing'))
8 |
9 | print(sorted(fruits, key=reverse))
10 |
11 |
12 | class C: pass
13 | obj = C()
14 | def func(): pass
15 | fun_prop = sorted(set(dir(func)) - set(dir(obj)))
16 | print(fun_prop)
17 |
--------------------------------------------------------------------------------
/Fluent_Python/ch06-dp-1class-func/README.rst:
--------------------------------------------------------------------------------
1 | Sample code for Chapter 6 - "Design patterns with first class functions"
2 |
3 | From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
4 | http://shop.oreilly.com/product/0636920032519.do
5 |
6 |
7 | classic_strategy.py 传统的策略默认, 继承抽象类(虚函数),重写虚函数的做法
8 | strategy_func.py 函数式编程
9 | strategy_best.py 在函数式编程的基础上,进一步优选“促销策略”
10 |
--------------------------------------------------------------------------------
/Fluent_Python/ch06-dp-1class-func/strategy_best/promotions.py:
--------------------------------------------------------------------------------
1 |
2 | def fidelity_promo(order):
3 | """5% discount for customers with 1000 or more fidelity points"""
4 | return order.total() * .05 if order.customer.fidelity >= 1000 else 0
5 |
6 |
7 | def bulk_item_promo(order):
8 | """10% discount for each LineItem with 20 or more units"""
9 | discount = 0
10 | for item in order.cart:
11 | if item.quantity >= 20:
12 | discount += item.total() * .1
13 | return discount
14 |
15 | def large_order_promo(order):
16 | """7% discount for orders with 10 or more distinct items"""
17 | distinct_items = {item.product for item in order.cart}
18 | if len(distinct_items) >= 10:
19 | return order.total() * .07
20 | return 0
21 |
--------------------------------------------------------------------------------
/Fluent_Python/ch06-dp-1class-func/strategy_func/c++_version/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread -lmuduo_net -lmuduo_base
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = code
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | code: CXXFLAGS += -Wall
18 | code: code.cc
19 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/README.rst:
--------------------------------------------------------------------------------
1 | Sample code for Chapter 7 - "Closures and decorators"
2 |
3 | From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
4 | http://shop.oreilly.com/product/0636920032519.do
5 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/average/average.py:
--------------------------------------------------------------------------------
1 | """
2 | >>> avg = make_averager()
3 | >>> avg(10)
4 | 10.0
5 | >>> avg(11)
6 | 10.5
7 | >>> avg(12)
8 | 11.0
9 | >>> avg.__code__.co_varnames
10 | ('new_value', 'total')
11 | >>> avg.__code__.co_freevars
12 | ('series',)
13 | >>> avg.__closure__ # doctest: +ELLIPSIS
14 | (,)
15 | >>> avg.__closure__[0].cell_contents
16 | [10, 11, 12]
17 | """
18 |
19 | DEMO = """
20 | >>> avg.__closure__
21 | (,)
22 | """
23 |
24 |
25 | def make_averager():
26 | series = []
27 |
28 | def averager(new_value):
29 | series.append(new_value)
30 | total = sum(series)
31 | return total/len(series)
32 |
33 | return averager
34 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/average/average_oo.py:
--------------------------------------------------------------------------------
1 | """
2 | >>> avg = Averager()
3 | >>> avg(10)
4 | 10.0
5 | >>> avg(11)
6 | 10.5
7 | >>> avg(12)
8 | 11.0
9 |
10 | """
11 |
12 |
13 | class Averager():
14 |
15 | def __init__(self):
16 | self.series = []
17 |
18 | def __call__(self, new_value):
19 | self.series.append(new_value)
20 | total = sum(self.series)
21 | return total/len(self.series)
22 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/clockdeco/clock_param/__pycache__/clockdeco_param.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch07-deco-closure/clockdeco/clock_param/__pycache__/clockdeco_param.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/clockdeco/clock_param/clockdeco_param_demo1.py:
--------------------------------------------------------------------------------
1 | import time
2 | from clockdeco_param import clock
3 |
4 | @clock('{name}: {elapsed}s')
5 | def snooze(seconds):
6 | time.sleep(seconds)
7 |
8 | for i in range(3):
9 | snooze(.123)
10 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/clockdeco/clock_param/clockdeco_param_demo2.py:
--------------------------------------------------------------------------------
1 | import time
2 | from clockdeco_param import clock
3 |
4 | @clock('{name}({args}) dt={elapsed:0.3f}s')
5 | def snooze(seconds):
6 | time.sleep(seconds)
7 |
8 | for i in range(3):
9 | snooze(.123)
10 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/clockdeco/clockdeco/clockdeco.py:
--------------------------------------------------------------------------------
1 | # clockdeco.py
2 |
3 | import time
4 |
5 |
6 | def clock(func):
7 | def clocked(*args):
8 | t0 = time.time()
9 | result = func(*args)
10 | elapsed = time.time() - t0
11 | name = func.__name__
12 | arg_str = ', '.join(repr(arg) for arg in args)
13 | print('[%0.8fs] %s(%s) -> %r' % (elapsed, name, arg_str, result))
14 | return result
15 | return clocked
16 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/clockdeco/clockdeco/clockdeco_demo.py:
--------------------------------------------------------------------------------
1 | # clockdeco_demo.py
2 |
3 | import time
4 | from clockdeco import clock
5 |
6 | @clock
7 | def snooze(seconds):
8 | time.sleep(seconds)
9 |
10 | @clock
11 | def factorial(n):
12 | if n<2:
13 | return 1
14 | else:
15 | return n*factorial(n-1)
16 |
17 | if __name__=='__main__':
18 | print('*' * 40, 'Calling snooze(.123)')
19 | snooze(.123)
20 | print('*' * 40, 'Calling factorial(6)')
21 | print('6! =', factorial(6))
22 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/clockdeco/clockdeco/fibo_demo.py:
--------------------------------------------------------------------------------
1 | # import functools
2 | from clockdeco import clock
3 |
4 | # @functools.lru_cache()
5 | @clock
6 | def fibonacci(n):
7 | if n<2:
8 | return n
9 | else:
10 | return fibonacci(n-2) + fibonacci(n-1)
11 |
12 | if __name__ == '__main__':
13 | print(fibonacci(30))
14 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/clockdeco/clockdeco/fibo_demo_lru.py:
--------------------------------------------------------------------------------
1 | import functools
2 | from clockdeco import clock
3 |
4 | @functools.lru_cache()
5 | @clock
6 | def fibonacci(n):
7 | if n<2:
8 | return n
9 | else:
10 | return fibonacci(n-2) + fibonacci(n-1)
11 |
12 | if __name__ == '__main__':
13 | print(fibonacci(30))
14 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/fibo_demo.py:
--------------------------------------------------------------------------------
1 | from clockdeco import clock
2 |
3 | @clock
4 | def fibonacci(n):
5 | if n < 2:
6 | return n
7 | return fibonacci(n-2) + fibonacci(n-1)
8 |
9 | if __name__=='__main__':
10 | print(fibonacci(6))
11 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/fibo_demo_lru.py:
--------------------------------------------------------------------------------
1 | import functools
2 |
3 | from clockdeco import clock
4 |
5 | @functools.lru_cache() # <1>
6 | @clock # <2>
7 | def fibonacci(n):
8 | if n < 2:
9 | return n
10 | return fibonacci(n-2) + fibonacci(n-1)
11 |
12 | if __name__=='__main__':
13 | print(fibonacci(6))
14 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/registration.py:
--------------------------------------------------------------------------------
1 | # BEGIN REGISTRATION
2 |
3 | registry = [] # <1>
4 |
5 | def register(func): # <2>
6 | print('running register(%s)' % func) # <3>
7 | registry.append(func) # <4>
8 | return func # <5>
9 |
10 | @register # <6>
11 | def f1():
12 | print('running f1()')
13 |
14 | @register
15 | def f2():
16 | print('running f2()')
17 |
18 | def f3(): # <7>
19 | print('running f3()')
20 |
21 | def main(): # <8>
22 | print('running main()')
23 | print('registry ->', registry)
24 | f1()
25 | f2()
26 | f3()
27 |
28 | if __name__=='__main__':
29 | main() # <9>
30 |
31 | # END REGISTRATION
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/registration_abridged.py:
--------------------------------------------------------------------------------
1 | # BEGIN REGISTRATION_ABRIDGED
2 | registry = []
3 |
4 | def register(func):
5 | print('running register(%s)' % func)
6 | registry.append(func)
7 | return func
8 |
9 | @register
10 | def f1():
11 | print('running f1()')
12 |
13 | print('running main()')
14 | print('registry ->', registry)
15 | f1()
16 | # END REGISTRATION_ABRIDGED
17 |
--------------------------------------------------------------------------------
/Fluent_Python/ch07-deco-closure/registration_param.py:
--------------------------------------------------------------------------------
1 | # BEGIN REGISTRATION_PARAM
2 |
3 | registry = set() # <1>
4 |
5 | def register(active=True): # <2>
6 | def decorate(func): # <3>
7 | print('running register(active=%s)->decorate(%s)'
8 | % (active, func))
9 | if active: # <4>
10 | registry.add(func)
11 | else:
12 | registry.discard(func) # <5>
13 |
14 | return func # <6>
15 | return decorate # <7>
16 |
17 | @register(active=False) # <8>
18 | def f1():
19 | print('running f1()')
20 |
21 | @register() # <9>
22 | def f2():
23 | print('running f2()')
24 |
25 | def f3():
26 | print('running f3()')
27 |
28 | # END REGISTRATION_PARAM
29 |
--------------------------------------------------------------------------------
/Fluent_Python/ch09-pythonic-obj/mem_test.py:
--------------------------------------------------------------------------------
1 | import importlib
2 | import sys
3 | import resource
4 |
5 | NUM_VECTORS = 10**7
6 |
7 | if len(sys.argv) == 2:
8 | module_name = sys.argv[1].replace('.py', '')
9 | module = importlib.import_module(module_name)
10 | else:
11 | print('Usage: {} '.format())
12 | sys.exit(1)
13 |
14 | fmt = 'Selected Vector2d type: {.__name__}.{.__name__}'
15 | print(fmt.format(module, module.Vector2d))
16 |
17 | mem_init = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
18 | print('Creating {:,} Vector2d instances'.format(NUM_VECTORS))
19 |
20 | vectors = [module.Vector2d(3.0, 4.0) for i in range(NUM_VECTORS)]
21 |
22 | mem_final = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
23 | print('Initial RAM usage: {:14,}'.format(mem_init))
24 | print(' Final RAM usage: {:14,}'.format(mem_final))
25 |
--------------------------------------------------------------------------------
/Fluent_Python/ch10-seq-hacking/README.rst:
--------------------------------------------------------------------------------
1 | Sample code for Chapter 10 - "Sequence hacking, hashing and slicing"
2 |
3 | From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
4 | http://shop.oreilly.com/product/0636920032519.do
5 |
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/frenchdeck_class/frenchdeck2.py:
--------------------------------------------------------------------------------
1 | import collections
2 |
3 | Card = collections.namedtuple('Card', ['rank', 'suit'])
4 |
5 | class FrenchDeck2(collections.MutableSequence):
6 | ranks = [str(n) for n in range(2, 11)] + list('JQKA')
7 | suits = 'spades diamonds clubs hearts'.split()
8 |
9 | def __init__(self):
10 | self._cards = [Card(rank, suit) for suit in self.suits
11 | for rank in self.ranks]
12 |
13 | def __len__(self):
14 | return len(self._cards)
15 |
16 | def __getitem__(self, position):
17 | return self._cards[position]
18 |
19 | def __setitem__(self, position, value): # <1>
20 | self._cards[position] = value
21 |
22 | def __delitem__(self, position): # <2>
23 | del self._cards[position]
24 |
25 | def insert(self, position, value): # <3>
26 | self._cards.insert(position, value)
27 |
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch11-iface-abc/tombola_class/__init__.py
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/bingo.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/bingo.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/drum.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/drum.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/lotto.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/lotto.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/tombola.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/tombola.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/tombolist.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch11-iface-abc/tombola_class/__pycache__/tombolist.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/bingo.py:
--------------------------------------------------------------------------------
1 | # BEGIN TOMBOLA_BINGO
2 |
3 | import random
4 | from tombola_class.tombola import Tombola
5 |
6 |
7 | class BingoCage(Tombola): # <1>
8 |
9 | def __init__(self, items):
10 | self._randomizer = random.SystemRandom() # <2>
11 | self._items = []
12 | self.load(items) # <3>
13 |
14 | def load(self, items):
15 | self._items.extend(items)
16 | self._randomizer.shuffle(self._items) # <4>
17 |
18 | def pick(self): # <5>
19 | try:
20 | return self._items.pop()
21 | except IndexError:
22 | raise LookupError('pick from empty BingoCage')
23 |
24 | def __call__(self): # <7>
25 | self.pick()
26 |
27 | # END TOMBOLA_BINGO
28 |
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/drum.py:
--------------------------------------------------------------------------------
1 | from random import shuffle
2 |
3 | from tombola_class.tombola import Tombola
4 |
5 |
6 | class TumblingDrum(Tombola):
7 |
8 | def __init__(self, iterable):
9 | self._balls = []
10 | self.load(iterable)
11 |
12 | def load(self, iterable):
13 | self._balls.extend(iterable)
14 | shuffle(self._balls)
15 |
16 | def pick(self):
17 | return self._balls.pop()
18 |
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/lotto.py:
--------------------------------------------------------------------------------
1 | # BEGIN LOTTERY_BLOWER
2 |
3 | import random
4 |
5 | from tombola_class.tombola import Tombola
6 |
7 |
8 | class LotteryBlower(Tombola):
9 |
10 | def __init__(self, iterable):
11 | self._balls = list(iterable) # <1>
12 |
13 | def load(self, iterable):
14 | self._balls.extend(iterable)
15 |
16 | def pick(self):
17 | try:
18 | position = random.randrange(len(self._balls)) # <2>
19 | except ValueError:
20 | raise LookupError('pick from empty BingoCage')
21 | return self._balls.pop(position) # <3>
22 |
23 | def loaded(self): # <4>
24 | return bool(self._balls)
25 |
26 | def inspect(self): # <5>
27 | return tuple(sorted(self._balls))
28 |
29 |
30 | # END LOTTERY_BLOWER
31 |
--------------------------------------------------------------------------------
/Fluent_Python/ch11-iface-abc/tombola_class/tombolist.py:
--------------------------------------------------------------------------------
1 | from random import randrange
2 |
3 | from tombola_class.tombola import Tombola
4 |
5 | @Tombola.register # <1>
6 | class TomboList(list): # <2>
7 |
8 | def pick(self):
9 | if self: # <3>
10 | position = randrange(len(self))
11 | return self.pop(position) # <4>
12 | else:
13 | raise LookupError('pop from empty TomboList')
14 |
15 | load = list.extend # <5>
16 |
17 | def loaded(self):
18 | return bool(self) # <6>
19 |
20 | def inspect(self):
21 | return tuple(sorted(self))
22 |
23 | # Tombola.register(TomboList) # <7>
24 |
--------------------------------------------------------------------------------
/Fluent_Python/ch12-inheritance/diamond.py:
--------------------------------------------------------------------------------
1 | class A:
2 | def ping(self):
3 | print('ping:', self)
4 |
5 |
6 | class B(A):
7 | def pong(self):
8 | print('pong:', self)
9 |
10 |
11 | class C(A):
12 | def pong(self):
13 | print('PONG:', self)
14 |
15 |
16 | class D(B, C):
17 |
18 | def ping(self):
19 | super().ping() # A.ping(self) 绕过mro,直接到达任意一个父类
20 | print('post-ping:', self)
21 |
22 | def pingpong(self):
23 | self.ping()
24 | super().ping()
25 | self.pong()
26 | super().pong()
27 | C.pong(self)
28 |
29 | if __name__ == '__main__':
30 | d = D()
31 | d.pong()
32 | C.pong(d)
33 |
34 | print(D.__mro__) # 经常查看每一个类的__mro__,分析调用优先级
35 | d.ping()
36 |
37 | d.pingpong()
38 |
39 |
--------------------------------------------------------------------------------
/Fluent_Python/ch13-op-overloading/bingo_addable/bingo.py:
--------------------------------------------------------------------------------
1 | # BEGIN TOMBOLA_BINGO
2 |
3 | import random
4 |
5 | from tombola import Tombola
6 |
7 |
8 | class BingoCage(Tombola): # <1>
9 |
10 | def __init__(self, items):
11 | self._randomizer = random.SystemRandom() # <2>
12 | self._items = []
13 | self.load(items) # <3>
14 |
15 | def load(self, items):
16 | self._items.extend(items)
17 | self._randomizer.shuffle(self._items) # <4>
18 |
19 | def pick(self): # <5>
20 | try:
21 | return self._items.pop()
22 | except IndexError:
23 | raise LookupError('pick from empty BingoCage')
24 |
25 | def __call__(self): # <7>
26 | self.pick()
27 |
28 | # END TOMBOLA_BINGO
29 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/aritprog/aritprog_float_error.py:
--------------------------------------------------------------------------------
1 | """
2 | Demonstrate difference between Arithmetic Progression calculated
3 | as a series of increments accumulating errors versus one addition
4 | and one multiplication.
5 | """
6 |
7 | from fractions import Fraction
8 | from aritprog_v0 import ArithmeticProgression as APv0
9 | from aritprog_v1 import ArithmeticProgression as APv1
10 |
11 | if __name__ == '__main__':
12 |
13 | ap0 = iter(APv0(1, .1))
14 | ap1 = iter(APv1(1, .1))
15 | ap_frac = iter(APv1(Fraction(1, 1), Fraction(1, 10)))
16 | epsilon = 10**-10
17 | iteration = 0
18 | delta = next(ap0) - next(ap1)
19 | frac = next(ap_frac)
20 | while abs(delta) <= epsilon:
21 | delta = next(ap0) - next(ap1)
22 | frac = next(ap_frac)
23 | iteration +=1
24 |
25 | print('iteration: {}\tfraction: {}\tepsilon: {}\tdelta: {}'.
26 | format(iteration, frac, epsilon, delta))
27 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v0.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v0.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v1.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v1.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v2.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v2.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v3.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/aritprog/class/__pycache__/aritprog_v3.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/aritprog/class/aritprog_v0.py:
--------------------------------------------------------------------------------
1 | """
2 | Arithmetic progression class
3 |
4 | >>> ap = ArithmeticProgression(1, .5, 3)
5 | >>> list(ap)
6 | [1.0, 1.5, 2.0, 2.5]
7 |
8 |
9 | """
10 |
11 |
12 | class ArithmeticProgression:
13 |
14 | def __init__(self, begin, step, end=None):
15 | self.begin = begin
16 | self.step = step
17 | self.end = end # None -> "infinite" series
18 |
19 | def __iter__(self):
20 | result = type(self.begin + self.step)(self.begin)
21 | forever = self.end is None
22 | while forever or result < self.end:
23 | yield result
24 | result += self.step
25 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/aritprog/class/aritprog_v3.py:
--------------------------------------------------------------------------------
1 | # BEGIN ARITPROG_ITERTOOLS
2 | import itertools
3 |
4 |
5 | def aritprog_gen(begin, step, end=None):
6 | first = type(begin + step)(begin)
7 | ap_gen = itertools.count(first, step)
8 | if end is not None:
9 | ap_gen = itertools.takewhile(lambda n: n < end, ap_gen)
10 | return ap_gen
11 | # END ARITPROG_ITERTOOLS
12 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/isis2json/cds.iso:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/isis2json/cds.iso
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/isis2json/cds.mst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/isis2json/cds.mst
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/isis2json/cds2.json:
--------------------------------------------------------------------------------
1 | { "docs" :
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_gen.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_gen.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_gen2.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_gen2.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_genexp.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_genexp.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_getitem.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_getitem.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_iter.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_iter.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_iter2.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch14-it-generator/sentence/class/__pycache__/sentence_iter2.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/sentence_gen.py:
--------------------------------------------------------------------------------
1 | """
2 | Sentence: iterate over words using a generator function
3 | """
4 |
5 | import re
6 | import reprlib
7 |
8 | RE_WORD = re.compile('\w+')
9 |
10 |
11 | class Sentence:
12 |
13 | def __init__(self, text):
14 | self.text = text
15 | self.words = RE_WORD.findall(text)
16 |
17 | def __repr__(self):
18 | return 'Sentence(%s)' % reprlib.repr(self.text)
19 |
20 | def __iter__(self):
21 | for word in self.words: # <1>
22 | yield word # <2>
23 | return # <3>
24 |
25 | # done! <4>
26 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/sentence_gen2.py:
--------------------------------------------------------------------------------
1 | """
2 | Sentence: iterate over words using a generator function
3 | """
4 |
5 | import re
6 | import reprlib
7 |
8 | RE_WORD = re.compile('\w+')
9 |
10 |
11 | class Sentence:
12 |
13 | def __init__(self, text):
14 | self.text = text # <1>
15 |
16 | def __repr__(self):
17 | return 'Sentence(%s)' % reprlib.repr(self.text)
18 |
19 | def __iter__(self):
20 | for match in RE_WORD.finditer(self.text): # <2>
21 | yield match.group() # <3>
22 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/sentence_getitem.py:
--------------------------------------------------------------------------------
1 | """
2 | Sentence: access words by index
3 | """
4 |
5 | import re
6 | import reprlib
7 |
8 | RE_WORD = re.compile('\w+')
9 |
10 |
11 | class Sentence:
12 |
13 | def __init__(self, text):
14 | self.text = text
15 | self.words = RE_WORD.findall(text) # <1>
16 |
17 | def __getitem__(self, index):
18 | return self.words[index] # <2>
19 |
20 | def __len__(self, index): # <3>
21 | return len(self.words)
22 |
23 | def __repr__(self):
24 | return 'Sentence(%s)' % reprlib.repr(self.text) # <4>
25 |
26 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/sentence/class/sentence_iter2.py:
--------------------------------------------------------------------------------
1 | """
2 | Sentence: iterate over words using the Iterator Pattern, take #2
3 |
4 | WARNING: the Iterator Pattern is much simpler in idiomatic Python;
5 | see: sentence_gen*.py.
6 | """
7 |
8 | import re
9 | import reprlib
10 |
11 | RE_WORD = re.compile('\w+')
12 |
13 |
14 | class Sentence:
15 |
16 | def __init__(self, text):
17 | self.text = text
18 |
19 | def __repr__(self):
20 | return 'Sentence(%s)' % reprlib.repr(self.text)
21 |
22 | def __iter__(self):
23 | word_iter = RE_WORD.finditer(self.text) # <1>
24 | return SentenceIter(word_iter) # <2>
25 |
26 |
27 | class SentenceIter():
28 |
29 | def __init__(self, word_iter):
30 | self.word_iter = word_iter # <3>
31 |
32 | def __next__(self):
33 | match = next(self.word_iter) # <4>
34 | return match.group() # <5>
35 |
36 | def __iter__(self):
37 | return self
38 |
--------------------------------------------------------------------------------
/Fluent_Python/ch14-it-generator/soapbox/yield_delegate/yield_delegate_fix.py:
--------------------------------------------------------------------------------
1 | """ Example adapted from ``yield_delegate_fail.py``
2 |
3 | The following program performs a simple abstraction over the process of
4 | yielding.
5 |
6 | """
7 |
8 | # BEGIN YIELD_DELEGATE_FIX
9 | def f():
10 | def do_yield(n):
11 | yield n
12 | x = 0
13 | while True:
14 | x += 1
15 | yield from do_yield(x)
16 | # END YIELD_DELEGATE_FIX
17 |
18 | if __name__ == '__main__':
19 | print('Invoking f() now produces a generator')
20 | g = f()
21 | print(next(g))
22 | print(next(g))
23 | print(next(g))
24 |
25 |
--------------------------------------------------------------------------------
/Fluent_Python/ch16-coroutine/c_impl/Makefile:
--------------------------------------------------------------------------------
1 | CXXFLAGS = -O0 -g3 -I ../.. -pthread #-g3可以让gdb展开宏, print命令
2 | LDFLAGS = -lpthread -lmuduo_net -lmuduo_base
3 | BASE_SRC =
4 | LIB_SRC =
5 | BINARIES = main
6 | HEADERS=$(wildcard *.h)
7 |
8 | all: $(BINARIES)
9 | $(BINARIES): $(HEADERS)
10 | $(BINARIES):
11 | g++ $(CXXFLAGS) -o $@ $(LIB_SRC) $(BASE_SRC) $(filter %.cc,$^) $(LDFLAGS)
12 |
13 | clean:
14 | rm -f $(BINARIES) core
15 |
16 |
17 | main: CXXFLAGS += -Wall
18 | main: main.cc coro.cc
19 |
20 |
--------------------------------------------------------------------------------
/Fluent_Python/ch16-coroutine/c_impl/coro.h:
--------------------------------------------------------------------------------
1 | #ifndef _CORO_H_
2 | #define _CORO_H_
3 |
4 | typedef void (*CoroFunType)(const void*);
5 |
6 | void coro_new(CoroFunType f, const void* arg);
7 | void coro_yield();
8 | void coro_main();
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/Fluent_Python/ch16-coroutine/c_impl/main.cc:
--------------------------------------------------------------------------------
1 | #include "coro.h"
2 | #include
3 | #include
4 |
5 | void co1(const void* msg)
6 | {
7 | for (int i = 0; i != 5; ++i)
8 | {
9 | printf("%s\n", (char*)msg);
10 | coro_yield();
11 | }
12 | }
13 |
14 | int main(int ac, char** av)
15 | {
16 | assert(sizeof(void*) == sizeof(unsigned long));
17 |
18 | coro_new(co1, "hello");
19 | coro_new(co1, "world");
20 | coro_main();
21 | return 0;
22 | }
23 |
--------------------------------------------------------------------------------
/Fluent_Python/ch16-coroutine/coroaverager/coroaverager1-prime/coroaverager1.py:
--------------------------------------------------------------------------------
1 | # BEGIN DECORATED_AVERAGER
2 | """
3 | A coroutine to compute a running average
4 | """
5 |
6 | from coroutil import coroutine # <4>
7 |
8 | @coroutine # <5> 增加了预激装饰器
9 | def averager(): # <6>
10 | total = 0.0
11 | count = 0
12 | average = None
13 | while True:
14 | term = yield average
15 | total += term
16 | count += 1
17 | average = total/count
18 | # END DECORATED_AVERAGER
19 |
20 | coro_avg = averager() # <1>
21 | from inspect import getgeneratorstate
22 | print(getgeneratorstate(coro_avg)) # <2> 'GEN_SUSPENDED'
23 | print(coro_avg.send(10)) # <3> 10.0
24 | print(coro_avg.send(30)) # 20.0
25 | print(coro_avg.send(5)) # 15.0
26 |
27 |
--------------------------------------------------------------------------------
/Fluent_Python/ch16-coroutine/coroaverager/coroaverager1-prime/coroutil.py:
--------------------------------------------------------------------------------
1 | # BEGIN CORO_DECO
2 | from functools import wraps
3 |
4 | def coroutine(func):
5 | """Decorator: primes `func` by advancing to first `yield`"""
6 | @wraps(func)
7 | def primer(*args,**kwargs): # <1>
8 | gen = func(*args,**kwargs) # <2>
9 | next(gen) # <3>
10 | return gen # <4>
11 | return primer
12 | # END CORO_DECO
13 |
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/__pycache__/flags.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/__pycache__/flags.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/bd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/bd.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/br.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/br.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/cd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/cd.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/cn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/cn.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/de.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/de.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/eg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/eg.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/et.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/et.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/fr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/fr.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/id.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/id.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/in.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/in.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/ir.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/ir.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/jp.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/jp.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/mx.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/mx.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/ng.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/ng.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/ph.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/ph.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/pk.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/pk.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/ru.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/ru.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/tr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/tr.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/us.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/us.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags/downloads/vn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags/downloads/vn.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/__pycache__/flags2_common.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/__pycache__/flags2_common.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/__pycache__/flags2_sequential.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/__pycache__/flags2_sequential.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/bd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/bd.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/br.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/br.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/cd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/cd.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/cn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/cn.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/de.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/de.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/eg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/eg.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/et.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/et.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/fr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/fr.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/id.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/id.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/in.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/in.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/ir.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/ir.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/jp.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/jp.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/mx.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/mx.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/ng.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/ng.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/ph.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/ph.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/pk.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/pk.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/ru.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/ru.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/tr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/tr.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/us.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/us.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch17-futures/flags2/downloads/vn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch17-futures/flags2/downloads/vn.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/charfinder/http_charfinder.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Charfinder
6 |
7 |
8 | Examples: {links}
9 |
10 |
14 | | |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/charfinder/requirements.txt:
--------------------------------------------------------------------------------
1 | aiohttp==0.13.1
2 |
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/bd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/bd.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/br.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/br.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/cd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/cd.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/cn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/cn.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/de.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/de.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/eg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/eg.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/et.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/et.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/fr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/fr.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/id.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/id.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/in.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/in.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/ir.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/ir.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/jp.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/jp.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/mx.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/mx.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/ng.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/ng.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/ph.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/ph.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/pk.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/pk.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/ru.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/ru.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/tr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/tr.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/us.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/us.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18-asyncio/flags/downloads/vn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18-asyncio/flags/downloads/vn.gif
--------------------------------------------------------------------------------
/Fluent_Python/ch18b-async-await/README.rst:
--------------------------------------------------------------------------------
1 | Refactored sample code for Chapter 18 - "Concurrency with asyncio"
2 |
3 | From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
4 | http://shop.oreilly.com/product/0636920032519.do
5 |
6 | ##################################################################
7 | NOTE: this "18b" directory contains the examples of chapter 18
8 | rewritten using the new async/await syntax available in Python 3.5
9 | ONLY, instead of the "yield-from" syntax which works since Python
10 | 3.3 (and will still work with Python 3.5).
11 | ##################################################################
12 |
--------------------------------------------------------------------------------
/Fluent_Python/ch18b-async-await/charfinder/__pycache__/charfinder.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18b-async-await/charfinder/__pycache__/charfinder.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch18b-async-await/charfinder/http_charfinder.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Charfinder
6 |
7 |
8 | Examples: {links}
9 |
10 |
14 |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Fluent_Python/ch18b-async-await/flags/imported/__pycache__/flags.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18b-async-await/flags/imported/__pycache__/flags.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch18b-async-await/flags/imported/__pycache__/flags2_common.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch18b-async-await/flags/imported/__pycache__/flags2_common.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch19-dyn-attr-prop/doc_property.py:
--------------------------------------------------------------------------------
1 | """
2 | Example of property documentation
3 |
4 | >>> f = Foo()
5 | >>> f.bar = 77
6 | >>> f.bar
7 | 77
8 | >>> Foo.bar.__doc__
9 | 'The bar attribute'
10 | """
11 |
12 | # BEGIN DOC_PROPERTY
13 | class Foo:
14 |
15 | @property
16 | def bar(self):
17 | '''The bar attribute'''
18 | return self.__dict__['bar']
19 |
20 | @bar.setter
21 | def bar(self, value):
22 | self.__dict__['bar'] = value
23 | # END DOC_PROPERTY
24 |
--------------------------------------------------------------------------------
/Fluent_Python/ch19-dyn-attr-prop/oscon/__pycache__/osconfeed.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/Fluent_Python/ch19-dyn-attr-prop/oscon/__pycache__/osconfeed.cpython-36.pyc
--------------------------------------------------------------------------------
/Fluent_Python/ch19-dyn-attr-prop/oscon/demo_schedule2.py:
--------------------------------------------------------------------------------
1 | import shelve
2 |
3 | from schedule2 import DB_NAME, CONFERENCE, load_db
4 | from schedule2 import DbRecord, Event
5 |
6 | with shelve.open(DB_NAME) as db:
7 | if CONFERENCE not in db:
8 | load_db(db)
9 |
10 | DbRecord.set_db(db)
11 | event = DbRecord.fetch('event.33950')
12 | print(event)
13 | print(event.venue)
14 | print(event.venue.name)
15 | for spkr in event.speakers:
16 | print('{0.serial}: {0.name}'.format(spkr))
17 |
18 | print(repr(Event.venue))
19 |
20 | event2 = DbRecord.fetch('event.33451')
21 | print(event2)
22 | print(event2.fetch)
23 | print(event2.venue)
--------------------------------------------------------------------------------
/Fluent_Python/ch19-dyn-attr-prop/oscon/test_schedule1.py:
--------------------------------------------------------------------------------
1 | import shelve
2 | import pytest
3 |
4 | import schedule1 as schedule
5 |
6 |
7 | @pytest.yield_fixture
8 | def db():
9 | with shelve.open(schedule.DB_NAME) as the_db:
10 | if schedule.CONFERENCE not in the_db:
11 | schedule.load_db(the_db)
12 | yield the_db
13 |
14 |
15 | def test_record_class():
16 | rec = schedule.Record(spam=99, eggs=12)
17 | assert rec.spam == 99
18 | assert rec.eggs == 12
19 |
20 |
21 | def test_conference_record(db):
22 | assert schedule.CONFERENCE in db
23 |
24 |
25 | def test_speaker_record(db):
26 | speaker = db['speaker.3471']
27 | assert speaker.name == 'Anna Martelli Ravenscroft'
28 |
29 |
30 | def test_event_record(db):
31 | event = db['event.33950']
32 | assert event.name == 'There *Will* Be Bugs'
33 |
34 |
35 | def test_event_venue(db):
36 | event = db['event.33950']
37 | assert event.venue_serial == 1449
38 |
--------------------------------------------------------------------------------
/Fluent_Python/ch19-dyn-attr-prop/pseudo_construction.py:
--------------------------------------------------------------------------------
1 | # pseudo-code for object construction
2 | def object_maker(the_class, some_arg):
3 | new_object = the_class.__new__(some_arg)
4 | if isinstance(new_object, the_class):
5 | the_class.__init__(new_object, some_arg)
6 | return new_object
7 |
8 | # the following statements are roughly equivalent
9 | x = Foo('bar')
10 | x = object_maker(Foo, 'bar')
11 |
--------------------------------------------------------------------------------
/Fluent_Python/ch20-descriptor/bulkfood/model_v4c.py:
--------------------------------------------------------------------------------
1 | # BEGIN MODEL_V4
2 | class Quantity:
3 | __counter = 0
4 |
5 | def __init__(self):
6 | cls = self.__class__
7 | prefix = cls.__name__
8 | index = cls.__counter
9 | self.storage_name = '_{}#{}'.format(prefix, index)
10 | cls.__counter += 1
11 |
12 | def __get__(self, instance, owner):
13 | if instance is None:
14 | return self
15 | else:
16 | return getattr(instance, self.storage_name)
17 |
18 | def __set__(self, instance, value):
19 | if value > 0:
20 | setattr(instance, self.storage_name, value)
21 | else:
22 | raise ValueError('value must be > 0')
23 | # END MODEL_V4
24 |
--------------------------------------------------------------------------------
/Fluent_Python/ch21-class-metaprog/README.rst:
--------------------------------------------------------------------------------
1 | Sample code for Chapter 21 - "Class metaprogramming"
2 |
3 | From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
4 | http://shop.oreilly.com/product/0636920032519.do
5 |
--------------------------------------------------------------------------------
/Fluent_Python/ch21-class-metaprog/evalsupport.py:
--------------------------------------------------------------------------------
1 | print('<[100]> evalsupport module start')
2 |
3 | def deco_alpha(cls):
4 | print('<[200]> deco_alpha')
5 |
6 | def inner_1(self):
7 | print('<[300]> deco_alpha:inner_1')
8 |
9 | cls.method_y = inner_1
10 | return cls
11 |
12 |
13 | class MetaAleph(type):
14 | print('<[400]> MetaAleph body')
15 |
16 | def __init__(cls, name, bases, dic):
17 | print('<[500]> MetaAleph.__init__')
18 |
19 | def inner_2(self):
20 | print('<[600]> MetaAleph.__init__:inner_2')
21 |
22 | cls.method_z = inner_2
23 |
24 |
25 | print('<[700]> evalsupport module end')
26 |
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/.cc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/activeion/Books_SourceCode/7c6c23d4c22aa0ad3c8f01b0bba962527bdc599e/In-depth_C++11/ch01-moderner_and_simpler/.cc
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-02_auto.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | class Foo
4 | {
5 | public:
6 | static int get(void)
7 | {
8 | return 0;
9 | }
10 | };
11 |
12 | class Bar
13 | {
14 | public:
15 | static const char* get(void)
16 | {
17 | return "0";
18 | }
19 | };
20 |
21 | template
22 | void func(void)
23 | {
24 | auto val = A::get();
25 |
26 | //...
27 | }
28 |
29 | int main(void)
30 | {
31 | func();
32 | func();
33 |
34 | return 0;
35 | }
36 |
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-03_decltype.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | class Foo
4 | {
5 | public:
6 | static const int Number = 0;
7 | int x;
8 | };
9 |
10 | int main(void)
11 | {
12 | int n = 0;
13 | volatile const int &x = n;
14 |
15 | decltype(n) a = n; //a -> int
16 | decltype(x) b = n; //b -> const volatile int &
17 |
18 | decltype(Foo::Number) c = 0; //c -> const int
19 |
20 | return 0;
21 | }
22 |
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-04_decltype.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | class Foo{};
4 |
5 | int& func_int_r(void); //左值(lvalue,可简单理解为可寻址值)
6 | int&& func_int_rr(void); //x值(xvalue,右值引用本身是一个xvalue)
7 | int func_int(void); //纯右值(pvalue)
8 |
9 | const int& func_cint_r(void); //左值
10 | const int&& func_cint_rr(void); //x值
11 | const int func_cint(void); //纯右值
12 |
13 | const Foo func_cfoo(void); //纯右值
14 |
15 | int main(void)
16 | {
17 | int x = 0;
18 |
19 | decltype(func_int_r()) a1 = x; //a1 -> int&
20 | decltype(func_int_rr()) b1 = 0; //b1 -> int&&
21 | decltype(func_int()) c1 = 0; //c1 -> int
22 |
23 | decltype(func_cint_r()) a2 = x; //a2 -> const int&
24 | decltype(func_cint_rr()) b2 = 0; //b2 -> const int&&
25 | decltype(func_cint()) c2 = 0; //c2 -> int
26 |
27 | decltype(func_cfoo()) ff = Foo(); //ff -> Foo
28 |
29 | system("pause");
30 | return 0;
31 | }
32 |
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-05_template.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | template
5 | class Foo
6 | {
7 | //typename ContainerT::iterator it_; //类型定义可能有问题
8 | //若想在 const ContainerT 下通过编译请使用下面it_定义:
9 | decltype(std::declval().begin()) it_;
10 | public:
11 | void func(ContainerT& container)
12 | {
13 | it_ = container.begin();
14 | }
15 |
16 | //...
17 | };
18 |
19 | int main(void)
20 | {
21 | typedef const std::vector container_t; //这里有const属性,编译会报一大堆错误信息
22 | container_t arr;
23 |
24 | Foo foo;
25 | foo.func(arr);
26 |
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-06_》.cc:
--------------------------------------------------------------------------------
1 | template
2 | struct Foo
3 | {
4 | typedef T type;
5 | };
6 |
7 | template
8 | class A
9 | {
10 | //...
11 | };
12 |
13 | int main(void)
14 | {
15 | Foo>::type xx; //C++98/03编译出错。
16 |
17 | return 0;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-07_init.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int i_arr[3] = { 1, 2, 3 }; //普通数组
4 |
5 | struct A
6 | {
7 | int x;
8 | struct B
9 | {
10 | int i;
11 | int j;
12 | } b;
13 | } a = { 1, {2, 3} }; //POD类型
14 |
15 | int i = 0;
16 |
17 | class Foo
18 | {
19 | public:
20 | Foo(int){}
21 | } foo = 123;
22 |
23 | int j(0);
24 |
25 | Foo bar(123);
26 |
27 | int main(void)
28 | {
29 |
30 | system("pause");
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-08_init.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | class Foo
4 | {
5 | public:
6 | Foo(int){}
7 |
8 | private:
9 | Foo(const Foo&);
10 | };
11 |
12 | int main(void)
13 | {
14 | Foo a1(123);
15 | //Foo a2 = a1; //error C2248: “Foo::Foo”: 无法访问 private 成员(在“Foo”类中声明)
16 | Foo a3 = { 123 };
17 | Foo a4{ 123 };
18 |
19 | int a5 = { 3 };
20 | int a6 { 3 };
21 |
22 | system("pause");
23 | return 0;
24 | }
25 |
--------------------------------------------------------------------------------
/In-depth_C++11/ch01-moderner_and_simpler/1-09_init.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include