Skip to content

Can STL be used? #2567

Answered by LeStarch
ConstStar asked this question in Q&A
Mar 6, 2024 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Like many shiny c++ features, a project may absolutely choose to use the standard template library (STL). It is absolutely required to work with some third-party code.

In F´ core, we don't allow STL simply because this code is used by many different projects some, which might choose to use STL and others that do not. The reasoning behind this is because the STL uses dynamic memory management to allocate memory for the object stored in things like the std::vector and this runtime memory allocation violates the "no allocation after initialization" rule. Hence many projects are wary of the STL.

There are ways to offset these allocations. A simple method would be to preallocate sizes for STL …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ConstStar
Comment options

@LeStarch
Comment options

@ConstStar
Comment options

Answer selected by ConstStar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants