Skip to content

Commit

Permalink
update the documentation regarding STL usage
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelflinger committed Jan 16, 2025
1 parent eac99e5 commit 3a8b264
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,21 @@ private:
- other headers are sorted in reverse order of their layering, that is, lower layer headers last
- within a layer, headers are sorted alphabetically
- strive for implementing one class per file
- `STL` limited in public headers to:
- `type_traits`
- `STL` limited in **filament** public headers to:
- `array`
- `initializer_list`
- `iterator`
- `limits`
- `optional`
- `type_traits`
- `utility`
- `variant`

For **libfilament** the rule of thumb is that STL headers that don't generate code are allowed (e.g. `type_traits`),
conversely containers and algorithms are not allowed. There are exceptions such as `array`. See above for the full list.
- The following `STL` headers a banned entirely, from public and private headers as well as implementation files:
- `iostream`


*Sorting the headers is important to help catching missing `#include` directives.*

Expand Down
6 changes: 3 additions & 3 deletions filament/backend/include/backend/DriverEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

#include <math/vec4.h>

#include <array> // FIXME: STL headers are not allowed in public headers
#include <type_traits> // FIXME: STL headers are not allowed in public headers
#include <variant> // FIXME: STL headers are not allowed in public headers
#include <array>
#include <type_traits>
#include <variant>

#include <stddef.h>
#include <stdint.h>
Expand Down

0 comments on commit 3a8b264

Please sign in to comment.