C++

1783 readers
1 users here now

The center for all discussion and news regarding C++.

Rules

founded 1 year ago
MODERATORS
201
202
203
 
 

A 3 hours talk by the great Timur!

Part 2 is here: https://inv.zzls.xyz/watch?v=5uIsadq-nyk

204
205
 
 

I'm learning C++ and as starting project I'd like to build a simple TUI program, something like neofetch. Do you have any suggestions of a good library I can use to manage the TUI? After some research I sumbled upon ncurses, which seems quite old tho, and notcurses, which to me looks quite cool. Which of the two would you recommend? Are there any better libraries? I thought that maybe, being quite widely used, ncurses is more worth learning, but I'm open to different opinions.

206
 
 

This one was quite a struggle, thought I'd share for the C++ programmers here.

I have a use case where for many function templates I have to instantiate them for a bunch of different parameter types, e.g. unary, binary and ternary functions where each argument can be one of 9 different types, giving 9, 9^2 = 81 or 9^3 = 729 instantiations of each function. Clearly I don't want to write those out as explicit template instantiations, and using macros is error prone too.

I've found this approach with std::variant and std::visit to be useful. Would appreciate any insight on edge cases where this may not work, or other suggested approaches.

207
3
submitted 1 year ago by lysdexic to c/cpp
208
209
10
submitted 1 year ago* (last edited 1 year ago) by jim_stark to c/cpp
 
 

I use Helix Editor and by default it uses clangd as LSP server.

But when I use "newer" C++20 features I get warning messages in the editor that they are only available in "later" C++ versions or I get straight up error messages.

So how do I tell clangd that I am writing C++20 code? I am guessing passing an argument (-std=c++20) or creating a "project properties" file...

This is the Helix Editor configuration file, languages.toml:

[[language]]
name = "cpp"
language-server = { command = "clangd", args = [] }
auto-format = true

Please let me know the right way to do it.

210
211
212
15
Speed Up C++ Compilation (devtalk.blender.org)
submitted 1 year ago by lysdexic to c/cpp
213
 
 

Recently I end up using structs everywhere as functions parameters to basically get named function parameters and better default arguments. Are there any downsides to this? So far the only annoying thing is to have to define those structs.

struct FunParams{
    int i = 5;
    float f = 3.14f;
    std::string s = "hello";
};

void Fun(const FunParams& params){}

int main(){
    Fun({.s = "hi there"});
}
214
215
216
217
218
219
220
6
submitted 1 year ago by lysdexic to c/cpp
221
222
15
submitted 1 year ago by [email protected] to c/cpp
223
 
 

I follow (probably too many) a bunch of news source regarding programming, and a few weeks ago I started putting everything in a RSS reader, so that I can a single feed/app to go to (instead of remembering every day/week to check x, y, a websites), so I made a script for totw/cpp to help them generate an RSS feed when a new tip is posted.

It might need a few more tweaks to be perfect (markdown to html to XML CDATA sometimes messes up), but it works well and I can finally enjoy reading tips easily anytime, and so can you!

224
 
 

im new in c++ and i am creating a version of cat for practicing what i have learned so far. What im doing for managing the command line arguments is converting them to library strings and then using them, but now i have the doubt if it is the correct / most optimal way to do it

225
 
 

Do you want to encrypt something and include it into your application? Don't want to use pre-build step? Encrypt it at compile-time! Decrypt it at run-time, assuming end-user knows the key or password. Plain-text is not stored inside your binary file. https://github.com/MarekKnapek/mk_clib#constexpr-aes-256-encryption-and-run-time-decryption

view more: ‹ prev next ›