1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

libcxx 実装メモのまとめ

Last updated at Posted at 2021-10-22

背景

libcxx の一部だったり全部を新アーキテクチャに対応したいとかしたいので, libcxx の実装を知りたい.

一般

libc++ == libcxx です.
gnustl(GCC STL)非依存を目指して開発されたっぽい?

メモ

一部コンパイラの builtin を使っているものがあります
(e.g __is_constructible)

libcxx での C++11 type_traits ソースコードツアーメモ
https://qiita.com/syoyo/items/12c35c0eccd759624866

libcxx std::hash 実装のメモ
https://qiita.com/syoyo/items/df31bad4d74c360b5f17

libcxx iostream cin 初期化メモ
https://qiita.com/syoyo/items/69e5bbae2b35e3fd0232

libc++ で parallel STL は対応していない(2021/10/06 clang-12 時点)
https://qiita.com/syoyo/items/03e955886bc404d93b45

Thread

pthread or Win32 thread を使っています.

variadic な引数を pack(?)するのに tuple を使っています.

include フォルダ

だいたい STL の名前でファイルが作られているのでわかりやすいです.
コード量が多いようなもの(e.g. memory でのスマポとか)は, __ prefix がついたフォルダに細かく機能ごとに追加されていたりします.

src フォルダ

thread の実装などが置かれています. これもファイルレイアウトはわかりやすいです.

実装上のメモ

  • _VSTD : std::ABI_VER なネームスペースのマクロです. libcxx 内部で std:: な関数など呼ぶときに使われています.

typeinfo

gcc, clang の場合, typeinfo をインクルードしないと typeid キーワードが使えずエラーになります. しかし自前 STL 実装で適当に typeinfo ファイルをでっちあげてもうまくいきません.

clang

clang のコードを見ると, std:: を定義しないとだめっぽい.

# include "mytype_info"

namespace std {
  using mystl::type_info;
} 

とすればいけるようです.

gcc

上記 clang のやりかただと type_info が二重定義だよとエラーになります.

T.B.W.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?