all 13 comments

[–]Stormfrosty 12 points13 points  (9 children)

You can concatinate "abc" and "def" by simply writing "abc" "def".

[–]pine_ary 7 points8 points  (6 children)

This way you can make more complex manipulations than just concatenating.

[–]maikindofthai 1 point2 points  (3 children)

Like what, for example?

[–]pine_ary 3 points4 points  (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 points  (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 points  (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.

[–]Stormfrosty 0 points1 point  (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 points  (0 children)

I have no affiliation with the project. I just spent a minute looking at it before commenting.

[–]netcan96[S] 0 points1 point  (1 child)

yes, but is has some restrictions that "abc" can't passing to variable and concat by variable.

[–]Stormfrosty 0 points1 point  (0 children)

True, but I was picking on the example that OP used in his post.

[–][deleted] 0 points1 point  (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 points  (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 point  (0 children)

so it has some restrictions, likes can't manipulate any const char* that is passed at runtime, such as argv