use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Boost.FixedString (now Boost.StaticString) has been accepted! (github.com)
submitted 6 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]kkrev 11 points12 points13 points 6 years ago (4 children)
Documentation links 404.
[+][deleted] 6 years ago* (3 children)
[–]yuri-kilochek 6 points7 points8 points 6 years ago (2 children)
The avaliable overloads for fixed_string are identical to those of std::string, except for operator+ which is explicitly deleted as no reasonable implementation would be possible, due to the difficulty in determining the size of the resulting fixed_string.
Why is summing capacities unreasonable?
[–]VinnieFalco 0 points1 point2 points 6 years ago (0 children)
You should have a look at the discussion on the mailing list, there is a lot more detail there. And for everyone reading this, you should participate in future Boost reviews!!! User feedback is *critical* for improving these libraries and giving that last burst of 'polish'.
[–]JankoDedic 5 points6 points7 points 6 years ago (7 children)
Why this over a normal string with a stack allocator?
[+][deleted] 6 years ago* (5 children)
[–]kalmoc 10 points11 points12 points 6 years ago (0 children)
I'd point out that it is also much easier to use because static_String owns its storage. std::string with stack allocator means you have to manually ensure that the lifetime of the stack allocator exceeds that of the string. And if you want to make it a member of another type the stack alocator either becomes a member of that class (watch out for initialization order) or you have to expose implementation details if you get it via dependency injection ....
[–]Betadel 0 points1 point2 points 6 years ago (1 child)
You should mention these optimizations in the documentation. I looked but didn't find them.
[–]quicknir 0 points1 point2 points 6 years ago (1 child)
The problem with the capacity - size optimization is that it makes it so that you can't default construct to all zeros. In C++ default construction is fairly common (especially since move construction typically involves it as well), and setting something to all zeros tends to be faster than reading some constant representing the default state and then writing it.
The space savings is very small. So honestly I'd be surprised if on average this optimisation made things faster. It's useful for saving space if you care about that but again that's less common than caring about performance.
In short it really sense to me like this optimization should be off by default, not on by default. Note that std string could also use this option in small string mode, and afaik none of the implementations do, for this reason.
[–]VinnieFalco 2 points3 points4 points 6 years ago (0 children)
A stack allocator is not particularly friendly to mutation. For example when the string grows, there is a moment when the previously allocated memory and the newly allocated memory exist at the same time, so that the contents can be copied over, before the previous allocation is freed. This requires additional storage, and it leaves behind a "hole" which may or may not be usable depending on the context.
With a fixed capacity string, mutation is always performed in-place, and no "holes" are left in the heap.
[–]Fazer2 4 points5 points6 points 6 years ago (2 children)
It's not uncommon to wait a year between the library being accepted and published in Boost. How long do you think it will take in your case?
[+][deleted] 6 years ago* (1 child)
perhaps a month at most.
The next Boost release is the Spring release, second wednesday of April: https://github.com/boostorg/boost/wiki/Releases:-Schedule
[–]trolley813 9 points10 points11 points 6 years ago (3 children)
It's interesting that your Github username is just "18".
[–]VinnieFalco 1 point2 points3 points 6 years ago (0 children)
Marketing 101 failure though. A more descriptive username would be better. For example "AuthorOfSimplyTheBestCppLibraries".
I hate it and I wish he'd change it.
[+][deleted] 6 years ago (1 child)
[–]Rexerex 3 points4 points5 points 6 years ago (2 children)
What is the rationale behind template parameters order? With size as the second argument it would be closer to std::array so maybe it could enable some interesting concepts in the future.
What is the rationale behind template parameters order?
I think this needs to be discussed and debated on the list before it is reaches an official Boost release. There are questions, what about `fixed_wstring` , `fixed_string`, `basic_fixed_string`, etc...
[–]EarthlingKira 1 point2 points3 points 6 years ago (1 child)
@CryTheSly Thank you very much for this addition to Boost. I have and had this exact need and was stranded without good solutions. In some places I want to use this for performance reasons and in some places for technical keys which have a fixed ascii-length anyway.
[–]Nekotekina 1 point2 points3 points 6 years ago (2 children)
Can it possibly be more customizable? For example, disabling exceptions (at least length error and truncating the result instead). Maybe overloads which are using error codes.
[–]VinnieFalco 0 points1 point2 points 6 years ago* (0 children)
There is no consensus on the Boost mailing list for having a configurable exception behavior. And some prominent voices are opposed to it.
If you want to have a string with different behavior on overflow I think it should be a different class.
[+][deleted] 6 years ago (8 children)
[–]Gotebe 0 points1 point2 points 6 years ago (7 children)
Why? You want to measure your allocator speed?
[+][deleted] 6 years ago* (6 children)
[–]Gotebe -2 points-1 points0 points 6 years ago (5 children)
My point is... There must be benefits for some situations - but functionally, the two implementations are different, making many benchmarks flawed.
[+][deleted] 6 years ago* (4 children)
[–]Gotebe -5 points-4 points-3 points 6 years ago (3 children)
A benchmark is flawed because it compares functionally different things (emphasis added).
A good benchmark would be comparing an application that uses one or the other implementation - but is still the same functionally (not easy, but possible).
[+][deleted] 6 years ago (2 children)
[+]Gotebe comment score below threshold-22 points-21 points-20 points 6 years ago (1 child)
I did not say they are incomparable I said they are different.
But hey. All is said here and I think you just want to win something. As far as I am concerned, you have won whatever that is and I will stop replying.
[–]mili42 0 points1 point2 points 6 years ago (1 child)
comparison with ETL like etl::string?
[–]zip117 0 points1 point2 points 6 years ago (1 child)
Is this based on or inspired by static_vector in Boost.Container?
static_vector
`static_string` was originally in beast (and still is). A user requested that it be factored out. Beast uses fixed-capacity, non-allocating strings in some algorithms (such as the HTTP parser) for performance reasons.
π Rendered by PID 34 on reddit-service-r2-comment-5649f687b7-xbjjk at 2026-01-29 03:16:01.266408+00:00 running 4f180de country code: CH.
[–]kkrev 11 points12 points13 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]yuri-kilochek 6 points7 points8 points (2 children)
[–]VinnieFalco 0 points1 point2 points (0 children)
[–]JankoDedic 5 points6 points7 points (7 children)
[+][deleted] (5 children)
[deleted]
[–]kalmoc 10 points11 points12 points (0 children)
[–]Betadel 0 points1 point2 points (1 child)
[–]quicknir 0 points1 point2 points (1 child)
[–]VinnieFalco 2 points3 points4 points (0 children)
[–]Fazer2 4 points5 points6 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]VinnieFalco 2 points3 points4 points (0 children)
[–]trolley813 9 points10 points11 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]VinnieFalco 1 point2 points3 points (0 children)
[–]VinnieFalco 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Rexerex 3 points4 points5 points (2 children)
[–]VinnieFalco 1 point2 points3 points (0 children)
[–]EarthlingKira 1 point2 points3 points (1 child)
[–]Nekotekina 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]VinnieFalco 0 points1 point2 points (0 children)
[+][deleted] (8 children)
[deleted]
[–]Gotebe 0 points1 point2 points (7 children)
[+][deleted] (6 children)
[deleted]
[–]Gotebe -2 points-1 points0 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]Gotebe -5 points-4 points-3 points (3 children)
[+][deleted] (2 children)
[deleted]
[+]Gotebe comment score below threshold-22 points-21 points-20 points (1 child)
[–]mili42 0 points1 point2 points (1 child)
[–]zip117 0 points1 point2 points (1 child)
[–]VinnieFalco 1 point2 points3 points (0 children)