Mcy/best – A C++ STL replacement

pie_flavor1 pts0 comments

GitHub - mcy/best: The Best Library: a C++ STL replacement · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

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

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

mcy

best

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star<br>434

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>36 Commits<br>36 Commits

.github/workflows

.github/workflows

best

best

third_party/fuchsia

third_party/fuchsia

.bazelrc

.bazelrc

.bazelversion

.bazelversion

.clang-format

.clang-format

.gitignore

.gitignore

BUILD

BUILD

LICENSE.inc

LICENSE.inc

LICENSE.md

LICENSE.md

MODULE.bazel

MODULE.bazel

MODULE.bazel.lock

MODULE.bazel.lock

README.md

README.md

bazel

bazel

format.sh

format.sh

View all files

Repository files navigation

best

The Best C++ Library

best is an "STL replacement" for C++20, in the spirit of projects like Abseil<br>and Folly. However, unlike those, it aims to completely replace the C++<br>standard library and some of the language's own primitives.

Goals and Design Philosophy

Our goal is not interop, nor backwards compatibility: it is total replacement of<br>40 years of tech debt. best is what you use if you must use C++, but really<br>hate the STL. Of course, you can use best alongside the standard library, and<br>best depends on it for many things. But best encourages you to use its<br>vocabulary types: you should pick the "best solution".

We will only support "reasonable" configurations: modern architectures, and<br>operating systems whose names are "Linux", "Darwin", and "WindowsNT". best<br>will be free-standing friendly where that is feasible.

best is not exception-friendly. Exceptions introduce performance<br>pessimizations and safe exception-safe code in C++ is difficult to write and<br>test. It will always require C++20 as a minimum, and will only ever support<br>recent Clang and GCC; if you need to build for windows, use clang-cl.

NB: CI currently only tests recent Clang on x86_64-unknown-linux-glibc. If<br>you want to bring up a new, reasonable platform, you should make sure to turn<br>on some kind of CI support.

The essence of best's design philosophy is to copy Rust where it makes sense<br>and to apply lessons learned from Abseil. Neither of these is obviously better,<br>so we pick the best designs from each.

This is the best library in spite of C++, not because of it.

Name

The library is called best, styled in monospace. You do not need to write<br>`best` in contexts where backticks are not interpreted as monospace<br>markup.

The name comes from an unofficial synonym for Abseil's namespace, absl: "A<br>Better Standard Library". Because much of this library is a response to Abseil,<br>it feels right that it should be better than "better", and therefore best.

The best name is also an excellent opportunity for puns, and the names of<br>important types and functions are chosen so that best::blah reads well. For<br>example, best::option, best::result, and best::choice are all named with<br>this convention in mind.

The best name is not intended to be braggadocious. I just think it's fun and<br>punny.

Building

best currently only supports building with Bazel 7. It includes a script,<br>./bazel, that will download Bazelisk, and then download Bazel, and run that,<br>ensuring the only build dependency is Bash. Bazel will download and install a<br>hermetic Clang toolchain.

best will only have one source-of-truth build system. If you want to use<br>best with CMake or a similar build system, you are on your own.

To run all of best's tests, simply run the following; you should not need to<br>download any dependencies.

./bazel test //...

Organization

best's code is organized into shallow subdirectories that capture different<br>pieces of functionality.

best/base - Basic types and functions; portability helpers.

best/cli - Utilities for building CLI applications.

best/container - Container types. We interpret any generic "wrapper" type as<br>a container.

best/func - Helpers for manipulating functions as first-class objects.

best/iter - Iterators and other functional programming types.

best/io - I/O primitives for interfacing with the operating system.

best/log...

best bazel library clang build search

Related Articles