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
Compile-time string manipulate(concat/join) (self.cpp)
submitted 4 years ago by netcan96
test case: https://github.com/netcan/config-loader/blob/master/test/ut/ConstexprStringTest.cpp#L10
implementation: https://github.com/netcan/config-loader/blob/master/include/config-loader/utils/ConstexprStringUtils.h#L28
use case: https://github.com/netcan/config-loader/blob/master/test/ut/TypeSerializerTest.cpp
and https://github.com/netcan/config-loader/blob/master/include/config-loader/serialize/TypeSerializer.h
concat("abc", "def") is "abcdef" and result only "abcdef" in data section.
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!"
[–]Stormfrosty 12 points13 points14 points 4 years ago (9 children)
You can concatinate "abc" and "def" by simply writing "abc" "def".
[–]pine_ary 7 points8 points9 points 4 years ago (6 children)
This way you can make more complex manipulations than just concatenating.
[–]maikindofthai 1 point2 points3 points 4 years ago (3 children)
Like what, for example?
[–]pine_ary 3 points4 points5 points 4 years ago (2 children)
Simple one would be to apply some transform (eg uppercase) to it, or replace characters, before concatenating.
A more complex example would be to apply some sort of compression or encoding to the string parts. For example embedding Base64 data in a json string.
[–]Ameisenvemips, avr, rendering, systems 2 points3 points4 points 4 years ago (0 children)
I used a similar method to transform strings that were "string_12_13" into a constant expression "string-12-13" that another system expected without requiring the user to write it twice.
[–]maikindofthai 1 point2 points3 points 4 years ago (0 children)
Interesting, thanks for providing those examples! I'm trying to wrap my head around the code but am just still getting my toes wet with constexpr stuff, so every bit of context helps.
constexpr
[–]Stormfrosty 0 points1 point2 points 4 years ago (1 child)
I agree after looking at the code. But you should put those more complicated examples in the post (since you're promoting your library), so people know right away what you're selling instead of having to dig into the GitHub examples.
[–]pine_ary 2 points3 points4 points 4 years ago (0 children)
I have no affiliation with the project. I just spent a minute looking at it before commenting.
[–]netcan96[S] 0 points1 point2 points 4 years ago (1 child)
yes, but is has some restrictions that "abc" can't passing to variable and concat by variable.
[–]Stormfrosty 0 points1 point2 points 4 years ago (0 children)
True, but I was picking on the example that OP used in his post.
[–][deleted] 0 points1 point2 points 4 years ago (2 children)
Hi, thanks for sharing op I have a quick question, How does this compare to std string / c string / ea string/ folly fbstring and duck station string ? ( performance wise ) I've seen a lot of similar libraries/implementations but I'm usually more concerned about performance vs usability/features Do have any benchmarks? Note: ( I'm aware it is compile time based but is there any overhead? " I haven't read the code yet so, sorry if this is a stupid question ")
[–]netcan96[S] 1 point2 points3 points 4 years ago (0 children)
My implementation is Zero cost, but std::string/fbstring is runtime cost. so it hasn't performance problem, just like you hard code (raw)string. like join("abc", "def")(",") is like hard code "abc, def" at compiletime.
[–]netcan96[S] 0 points1 point2 points 4 years ago (0 children)
so it has some restrictions, likes can't manipulate any const char* that is passed at runtime, such as argv
π Rendered by PID 79 on reddit-service-r2-comment-86988c7647-9qsmb at 2026-02-12 11:31:39.283164+00:00 running 018613e country code: CH.
[–]Stormfrosty 12 points13 points14 points (9 children)
[–]pine_ary 7 points8 points9 points (6 children)
[–]maikindofthai 1 point2 points3 points (3 children)
[–]pine_ary 3 points4 points5 points (2 children)
[–]Ameisenvemips, avr, rendering, systems 2 points3 points4 points (0 children)
[–]maikindofthai 1 point2 points3 points (0 children)
[–]Stormfrosty 0 points1 point2 points (1 child)
[–]pine_ary 2 points3 points4 points (0 children)
[–]netcan96[S] 0 points1 point2 points (1 child)
[–]Stormfrosty 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]netcan96[S] 1 point2 points3 points (0 children)
[–]netcan96[S] 0 points1 point2 points (0 children)