Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Learning how the C++ Standard Library works; by implementation

License

NotificationsYou must be signed in to change notification settings

WillBrennan/learn_stl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learning about the C++ Standard Library by Implementation

Ever wondered how std::tuple is implemented? How std::get works? Well I started implementing this to find out just that.

The standard library heavily relies on manyC++ Idioms and unusual language features, by implementing the library you can get a bit more familiar with them!

Each of the components have documentation in/docs explaining how they work, what idioms the use, and whats interesting about them.

Hopefully you'll find this an interesting read!

Feel free to submit a PR adding more components or improving library / documentation!

Vocab Types

Any is the de-facto type-erasure method in C++, it provides type-safe container for single values of any type. The implementation provides an introduction to polymorphism in C++.

How can you store an object without a default-constructor on the stack? Well with aunion is how, but what is this weird special type.

Tuple heavily depends on variadic templates andstd::index_sequence, and isn't obvious how its implemented. It's a refreshing look atfeatures which aren't used day-to-day.

Another component thats heavily dependent on variadic templates, it employs more template metaprogramming tricks thantuple. It also provides an interesting use case ofaligned_storage.

Containers

Array is deceptively simple, but how are its constructors and destructors implicity declared? Why is array constexpr but vector isn't, and what is aggregate-initialization?Understanding Array requires a strong comprehension of these often over-looked language features.

Everyone knowsstd::vector right? But why is reserving so important? And what isstd::allocator and why wrap it instd::allocator_traits?

valarray provides an introduction to expression-templates. It stores elements in a vector, and it provides element-wise unary and binary operations. It won't create any temporaries and will only perform one iteration as it evaluates the expression for each resultant element.

Memory Mangement

unique_ptr is pretty simple, but its always good to understand whatstd::default_deleter does and how dangerous aggregate initialisation can be

addressof might seem like a verbose way of calling&T; but why does it exist? And why is it constexpr in C++17 and what does a constexpr pointer mean?

allocator is relatively simple, but why does it defineis_always_equal andpropagate_on_container_move_assignment.

About

Learning how the C++ Standard Library works; by implementation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

    Packages

    No packages published

    [8]ページ先頭

    ©2009-2025 Movatter.jp