1
11
submitted 6 days ago by [email protected] to c/[email protected]
2
7
std::try_cast and (const&&)=delete (quuxplusone.github.io)
submitted 1 week ago by [email protected] to c/[email protected]
3
14
submitted 1 week ago by [email protected] to c/[email protected]
4
11
submitted 2 weeks ago by [email protected] to c/[email protected]
5
4
submitted 2 weeks ago by [email protected] to c/[email protected]
6
6
submitted 2 weeks ago by [email protected] to c/[email protected]
7
6
submitted 2 weeks ago by [email protected] to c/[email protected]
8
8
submitted 2 weeks ago by [email protected] to c/[email protected]

I wrote a blog post comparing several range libraries for a case that is doing filter with non-trivial lambda and then reverse.

9
11
Needlessly Public (euroquis.nl)
submitted 1 month ago by [email protected] to c/[email protected]
10
23
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/[email protected]

I have been programming in C++ for a very long time, and like a lot of us, I have an established workflow that hasn't really changed much over time. With the exception of bare-metal programming for embedded systems, though, I have been developing for Windows that entire time. With the recent "enshittification" of Windows 11, I'm starting to realize that it's going to be time to make the switch to Linux in the very near future. I've become very accustomed to (spoiled by?) Visual Studio, though, and I'm wondering about the Linux equivalent of features I probably take for granted.

  • Debugging: In VS, I can set breakpoints, step through my code line-by-line, pause and inspect the contents of variable on-the-fly, switch between threads, etc. My understanding of Linux programming is that it's mostly done in a code editor, then compiled on the command line. How exactly do you debug code when your build process is separate from your code editor? Having to compile my code, run it until I find a bug, then open it up in a debugger and start it all over sounds extremely inefficient.
  • Build System: I'm aware that cmake exists, and I've used it a bit, but I don't like it. VS lets me just drop a .h and .cpp file into the solution explorer and I'm good-to-go. Is there really no graphical alternative for Linux?

It seems like Linux development is very modular; each piece of the development process exists in its own application, many of which are command-line only. Part of what I like about VS is that it ties this all together into a nice package and allows interoperability between the functions. I can create a new header or source file, add some code, build it, run it, and debug it, all within the same IDE.

This might come across as a rant against Linux programming, but I don't intend it to. I guess what I'm really looking for is suggestions on how to make the transition from a Visual Studio user to a Linux programmer. How can I transition to Linux and still maintain an efficient workflow?

As a note, I am not new to Linux; I have used it extensively. However, the only programming I've done on Linux is bash scripting.

11
16
submitted 1 month ago by [email protected] to c/[email protected]
12
13
submitted 2 months ago by [email protected] to c/[email protected]
13
13
wxWidgets 3.2.5 Released (www.wxwidgets.org)
submitted 2 months ago by [email protected] to c/[email protected]
14
3
submitted 2 months ago by [email protected] to c/[email protected]
15
4
submitted 2 months ago by [email protected] to c/[email protected]
16
6
submitted 2 months ago by [email protected] to c/[email protected]
17
7
submitted 2 months ago by [email protected] to c/[email protected]
18
17
submitted 2 months ago by [email protected] to c/[email protected]
19
13
GCC 14.1 Released (gcc.gnu.org)
submitted 2 months ago by [email protected] to c/[email protected]
20
14
submitted 2 months ago by [email protected] to c/[email protected]
21
13
submitted 2 months ago by [email protected] to c/[email protected]
22
15
submitted 2 months ago by [email protected] to c/[email protected]
23
14
submitted 2 months ago by [email protected] to c/[email protected]
24
18
submitted 2 months ago by [email protected] to c/[email protected]

In c++17, std::any was added to t he standard library. Boost had their own version of "any" for quite some time before that.

I've been trying to think of a case where std::any is the best solution, and I honestly can't think of one. std::any can hold a variable of any type at runtime, which seems incredibly useful until you consider that at some point, you will need to actually use the data in std::any. This is accomplished by calling std::any_cast with a template argument that corresponds to the correct type held in the std::any object.

That means that although std::any can hold a type of any object, the list of valid objects must be known at the point that the variable is any_cast out of the std::any object. While the list of types that can be assigned to the object is unlimited, the list of types that can be extracted from the object is still finite.

That being said, why not just use a std::variant that can hold all the possible types that could be any_cast out of the object? Set a type alias for the std::variant, and there is no more boilerplate code than you would have otherwise. As an added benefit, you ensure type safety.

25
5
submitted 3 months ago by [email protected] to c/[email protected]
view more: next ›

C++

1651 readers
1 users here now

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

Rules

founded 1 year ago
MODERATORS