r_cpp | Unsorted

Telegram-канал r_cpp - C++ - Reddit

-

Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels

Subscribe to a channel

C++ - Reddit

Atari Breakout for DOS

I made an Atari Breakout clone for DOS using turbo c++ 3.0. It wasn't easy; small things in modern systems are absolute headache on this ancient machines. I struggled with flickering problems, handling the keyboard interrupt , and even displaying the score since on VGA mode 13 putting pixel is only allowed so I had to implement a custom font rendering solution. But I'm happy for the result.

You can check out the GitHub repository:
https://github.com/ms0g/breakout

https://redd.it/1aoql3w
@r_cpp

Читать полностью…

C++ - Reddit

Using C++ as a Scripting Language, part 12: RPC
https://fwsgonzo.medium.com/using-c-as-a-scripting-language-part-12-fe912786de5e

https://redd.it/1aogt2v
@r_cpp

Читать полностью…

C++ - Reddit

syntaxs in Codelite is not colored

I`m switching lapton and desktop pc. On laptom is everything fine, nicely colored, but on desktop names of variables and syntax like cout, cin are white. Setting on both machines are idetical. Im curretnly in midlle of udemi beginner course and that coloring is realy helpful for me.
Uncle Google didnt help me, i didnt find anything here on reddit and I dont known where else find solution.

https://redd.it/1aoa4fg
@r_cpp

Читать полностью…

C++ - Reddit

Optimizing the `pext` perfect hash function
https://xoranth.net/verb-parse/

https://redd.it/1ao6asq
@r_cpp

Читать полностью…

C++ - Reddit

C++ Show and Tell - January 2024

Happy new year!

Use this thread to share anything you've written in C++. This includes:

* a tool you've written
* a game you've been working on
* your first non-trivial C++ program

The rules of this thread are very straight forward:

* The project must involve C++ in some way.
* It must be something you (alone or with others) have done.
* Please share a link, if applicable.
* Please post images, if applicable.

If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.

Last month's thread: https://www.reddit.com/r/cpp/comments/1889qph/c_show_and_tell_december_2023/

https://redd.it/18xdwh1
@r_cpp

Читать полностью…

C++ - Reddit

Modern usage of C++?

Hi I’m starting my 3rd year in my CS degree and completed a C++ dev internship. The codebase is old and uses C++ with MFC. The product is server/desktop applications for video streaming, and I worked on backend.

E.g. my main project was upgrading the in-house FTP libraries (built from the winsock level up) to use openssl for FTP over TLS communication.

Is this stuff essentially legacy? I LOVE C++ and want to work at startups on cutting-edge tech, am not interested in finance/game dev. I’m considering joining my peers and grinding Python/Javascript instead. (Btw I want to make tons of money lol so am not into cybersecurity etc)

https://redd.it/18wszc4
@r_cpp

Читать полностью…

C++ - Reddit

How Close Is Existing C/C++ Code to a Safe Subset? (PDF)
https://mdpi-res.com/d_attachment/jcp/jcp-04-00001/article_deploy/jcp-04-00001.pdf?version=1703739057

https://redd.it/18tams5
@r_cpp

Читать полностью…

C++ - Reddit

C++ time_point wackiness across platforms
https://rachelbythebay.com/w/2024/01/01/chrono/

https://redd.it/18wj7bp
@r_cpp

Читать полностью…

C++ - Reddit

Enforcing that static local variables only exist once | think-cell
https://www.think-cell.com/en/career/devblog/enforcing-that-static-local-variables-only-exist-once

https://redd.it/18soses
@r_cpp

Читать полностью…

C++ - Reddit

Learning Material: Value categories and types in C++

I have finally uploaded the slides of (a bit old but still relevant) a 2-part C++ presentation on value categories and types.
It was mainly to uncover/summarize some of the arcane workings of rvalue and lvalue stuff
and how to understand them by starting from the less know fact that every expression in C++ has a value category and a type etc.

This was the aftermath after Meeting C++ in Berlin in 2018.
Feel free to use these as a learning input etc.

Note:
The slides are still in German, by time and request I might translate it to English.
Translations and corrections are welcome!

https://redd.it/18sw46o
@r_cpp

Читать полностью…

C++ - Reddit

C++23, where are you?

We are at the end of 2023 (well still a few days) and the 2023 edition of C++ has not been published yet by ISO. According to the ISO C++ page, the status is "40.99", which means it's still far from "60.60" (publication). Anyone knows why there is such a delay? Will the next version of C++ be C++24 if it is published in 2024?

https://redd.it/18sxow0
@r_cpp

Читать полностью…

C++ - Reddit

What's the most horrifying thing you've done with templates?

I'm currently making a small state machine at compile time....

https://redd.it/18t598l
@r_cpp

Читать полностью…

C++ - Reddit

What are the best companies to work for using c++?



https://redd.it/18uj6vj
@r_cpp

Читать полностью…

C++ - Reddit

Daily bit(e) of C++ is now one year old
https://github.com/HappyCerberus/daily-bite-cpp

https://redd.it/18w4xei
@r_cpp

Читать полностью…

C++ - Reddit

C++ Jobs - Q1 2024

Rules For Individuals
---------------------

* **Don't** create top-level comments - those are for employers.
* Feel free to reply to top-level comments with **on-topic** questions.
* I will create top-level comments for **meta** discussion and **individuals looking for work**.

Rules For Employers
-------------------

* If you're hiring **directly**, you're fine, skip this bullet point. If you're a **third-party recruiter**, see the extra rules below.
* **One** top-level comment per employer. If you have multiple job openings, that's great, but please consolidate their descriptions or mention them in replies to your own top-level comment.
* **Don't** use URL shorteners. [reddiquette][] forbids them because they're opaque to the spam filter.
* Templates are awesome. Please **use** the following template. As the "formatting help" says, use \*\*two stars\*\* to **bold text**. Use empty lines to separate sections.
* **Proofread** your comment after posting it, and edit any formatting mistakes.

---

\*\*Company:\*\* [Company name; also, use the "formatting help" to make it a link to your company's website, or a specific careers page if you have one.]

 

\*\*Type:\*\* [Full time, part time, internship, contract, etc.]

 

\*\*Compensation:\*\* [This section is **optional**, and you can omit it without explaining why. However, including it will help your job posting stand out as there is [extreme demand][] from candidates looking for this info. If you choose to provide this section, it must contain (a range of) **actual numbers** - don't waste anyone's time by saying "Compensation: Competitive."]

 

\*\*Location:\*\* [Where's your office - or if you're hiring at multiple offices, list them. If your workplace language isn't English, please specify it.]

 

\*\*Remote:\*\* [Do you offer the option of working remotely? If so, do you require employees to live in certain areas or time zones?]

 

\*\*Visa Sponsorship:\*\* [Does your company sponsor visas?]

 

\*\*Description:\*\* [What does your company do, and what are you hiring C++ devs for? How much experience are you looking for, and what seniority levels are you hiring for? The more details you provide, the better.]

 

\*\*Technologies:\*\* [Required: what version of the C++ Standard do you mainly use? Optional: do you use Linux/Mac/Windows, are there languages you use in addition to C++, are there technologies like OpenGL or libraries like Boost that you need/want/like experience with, etc.]

 

\*\*Contact:\*\* [How do you want to be contacted? Email, reddit PM, telepathy, gravitational waves?]

---

Extra Rules For Third-Party Recruiters
--------------------------------------
Send modmail to request pre-approval on a case-by-case basis. We'll want to hear what info you can provide (in this case you can withhold client company names, and compensation info is still recommended but optional). We hope that you can connect candidates with jobs that would otherwise be unavailable, and we expect you to treat candidates well.

Previous Post
-------------

* [C++ Jobs - Q4 2023](https://www.reddit.com/r/cpp/comments/16xr6v6/c_jobs_q4_2023/)

[reddiquette]: https://support.reddithelp.com/hc/en-us/articles/205926439
[extreme demand]: https://www.reddit.com/r/cpp/comments/sz0cd5/c_jobs_threads_should_include_salarycompensation/

https://redd.it/18w2e6a
@r_cpp

Читать полностью…

C++ - Reddit

C++ Club 169: WG21 Mailings, Contracts, C++ Ecosystem
https://youtu.be/-G7HU_zOD6U

https://redd.it/1aog2qy
@r_cpp

Читать полностью…

C++ - Reddit

Benchmark Abseil btreeset, Boost flatset, Seq flatset and GCC std::set

[
https://imgur.com/a/Eo9H9gL](https://imgur.com/a/Eo9H9gL)

Somebody asked for benchmarks of btree-based ordered containers the other day.
Surprisingly, I couldn't find much data online so I ran a few myself.
I found the results interesting and thought you might too.

Benchmarked containers are:
\- Google [abseil btree\
set](https://abseil.io/about/design/btree) (Jan 2024)
\- Boost flat\_set (v1.84) backed by:
\- std::vector
\- indivi::devector (centered-data policy)
\- Seq flat\_set (1.1.0, backed by tiered_vector)
\- MinGW std::set (8.1)

I didn't took time to benchmark map variants (but expect somehow similar results).

Benchmark configuration:
\- OS: Windows 10 64-bits
\- Compiler: MinGW 8.1.0 64-bits
\- Flags: -O2 -DNDEBUG -march=native -mtune=native
\- CPU: i7-10875h, frequency scaling off (L1-D 32K, L1-I 32K, L2 256K, L3 16M)
\- String length: 31 Bytes (no sso)

Is it in line with what you were expecting from these containers?

https://redd.it/1aobm28
@r_cpp

Читать полностью…

C++ - Reddit

Move from rvalue Ranges in Ranges Algorithms

There are a couple of standard algorithms, that will copy elements from a source range to a destination range. Particularly the copy family, such as copy, copy_if, copy_n and copy_backward. Also there is sample, set_difference and probably more, for which this question applies.

For the old iterator-based overloads the lengthy std::make_move_iterator could be used, to make these algorithms move the elements from the source range to the destination range. With the C++20 ranges overloads this does not work as easily. Particularly std::ranges::copy(std::move(source), std::back_inserter(dest)) will not move the elements from source, but copy them. I am aware, that with C++23, we will be able to do std::ranges::copy(source | std::views::as_rvalues, std::back_inserter(dest)) and it is not hard to implement as_rvalue via transform until then.

However, i feel like the ranges algorithms should move elements from an rvalue range, making the variant using std::move work. I have recently come across this in a code review, where someone refactored pre-ranges-variants using make_move_iterator. The changes looked great at first, but then i checked and found that they do not work as intended. But i do understand why one would expect that.
Is there any general problem i am missing? Does the standard forbid this for some reason? Or is this just an optimization that has not yet been implemented yet by any of the three main standard library implementations? (Cmp. godbolt)

I am aware, that there are move equivalents for copy and copy_backwards. But not for any of the other cases. And still, in generic code it would be much nicer if the standard algorithms could decide if it was okay to move from a range (when it is an rvalue) or not.

https://redd.it/1ao5uz3
@r_cpp

Читать полностью…

C++ - Reddit

mraylib: Writing a C++23 ray tracer using senders/receivers (P2300) framework

Frustrated from my boring day job, I decided to write a ray tracer from scratch.

Repo link: mraylib

There were following motivations for writing a ray tracer despite of having multiple existing once:

1. Executor agnostic: I have seen multiple ray tracers for thread pool or cuda, etc. But I wanted to write a generic one as that would be right fit for the library. I feel P2300's sender/receiver framework is the right tool for the same.
2. Pure Algorithmic: Many ray tracers seem to provide their own implementation of frame, etc. I wanted this project to be pure algorithmic. My way was to discover the generic concept underlying these algorithms and depend on those concepts rather than on some concrete implementations. Users can have third party type modelling concept for their usecase.
3. Design by contract: Inspired by Sean Parent and Dave Abrahams talks on design by contract and many other Sean Parent talks, I wanted to try this on some real projects and ray tracing was the one. I tried composing algorithms by composing contracts and it was a sweet experience.

TBH C++'s value semantics really helped me to achieve the above. It was also fun to try some C++23 range algorithms and monadic optional.

I welcome any feedback on both the project itself and its codebase.

Thanks.

https://redd.it/1ao2ez0
@r_cpp

Читать полностью…

C++ - Reddit

Can we claim that std::deque is the most underrated STL container?

This thing has been there since before C++98?? And yet, I haven't really seen people mentioning it. They treat it like it doesn't exist. Do people really not use it in production code?

I read a bit about it on cppreference and I think it's a marvelous container. Really. It's like the std::vector but improved since it let's you add elements to the back and front at an O(1) time complexity (without doing shifts). And it's not trash like a linked-list (i.e. it has O(1) random access similar to the STL vector).

The only meaningful downside might be the double pointer dereference it has to do in every access. So it involves two levels of indirection and thus it's less cache-friendly.

What's your thoughts about std::deque? Do you even use it?

https://redd.it/18x1mty
@r_cpp

Читать полностью…

C++ - Reddit

A pragmatic approach to memory safety

I have wondered how hard it would be to create a compiler extension for c++ that allows specifying a safe block. In this block only value semantics are allowed along with unique and shared pointers. This would obviously prevent using much of the standard library(or any library), but it seems like it would be trivial to make that subset provably safe. If you need to modify an object without copying it and returning the copied value, you can just move a unique pointer into it and returning that unique pointer back.

https://redd.it/18sk6b5
@r_cpp

Читать полностью…

C++ - Reddit

How to use the openvpn3 library in qt

So I have been struggling with this library for a while now. I understand that the OpenVPN3 library works by including the header files in your project and directly linking it, I just don't know where to start and how to use it. This is the library I'm referring to (I'm using windows):

https://github.com/OpenVPN/openvpn3

https://redd.it/18wkv4a
@r_cpp

Читать полностью…

C++ - Reddit

C++ For Distributed Systems

I'm curious about the state of C++ in distributed systems and database engines. Is C++ still actively being used for development of new features in these domains?

I ask because I intend to move into this domain and I'm trying to determine what language I should focus on. I know getting into distributed systems involves knowing more about the concepts (I know a fair amount) than the language but if I want to contribute to open source (as I intend to do), the language I choose to work on will matter.

So far, it seems like there's a lot of noise around Go and Rust in this domain, with a lot of projects being written in these. Some of the ones I know of are below

* [TiKV](https://github.com/tikv/tikv) -> Rust
* [NeonDB](https://github.com/neondatabase/neon) -> Rust
* [TiDB](https://github.com/pingcap/tidb) -> Go
* [InfluxDB](https://github.com/influxdata/influxdb) -> Rust
* [CockroachDB](https://github.com/cockroachdb/cockroach) -> Go
* [Badger](https://github.com/dgraph-io/badger) -> Go
* [Vitess](https://github.com/vitessio/vitess) -> Go

It seems like there's a lot more projects being started or ported over to Rust from C++ and a lot of projects written in Go. However, I've also seen a lot of hype trains and I want to make sure that if I choose to switch focus from a battle tested language like C++ to something else, I have good reason to do so.

https://redd.it/18wj2bh
@r_cpp

Читать полностью…

C++ - Reddit

Handling constructors that could fail: Exceptions, Static Factory Method, or something else?

I have a texture class that takes a path to an image, and attempts to read the image and store its contents and data. Currently there's 3 things that can go wrong.

1. The path might not exist
2. The file might not be a valid image file (doesn't have a valid extension)
3. The file contains nonsense data, and therefore can't be read properly

I don't necessarily want to crash the program if one of these were to occur. I also don't like the idea of having an object that hasn't been properly constructed. I know I can use exceptions, but I've been taught to think of exceptions as critical errors, so they don't seem like the correct tool to me. The solution I like to most is to make the constructor private and move all the code that could produce an error over to a static method that returns a std::variant that holds either a complete texture object, or some error object outlining what went wrong. In the world of C++, is this a good way of handling a scenario like this? Are exceptions better? Is there something else?

https://redd.it/18wgjtc
@r_cpp

Читать полностью…

C++ - Reddit

My favourite memory leak - Björn Fahller - Meeting C++ 2023
https://www.youtube.com/watch?v=LKKmPAQFNgE

https://redd.it/18svlgj
@r_cpp

Читать полностью…

C++ - Reddit

CppCast: 2023 Holiday Special
https://cppcast.com/2023_holiday_special/

https://redd.it/18tjzc8
@r_cpp

Читать полностью…

C++ - Reddit

Probably the first C++20 modules open-source Linux project

C++ Modules have been introduced with C++20 for more than three years, but they are still not widely seen in open-source projects. There used to be one project, async_simple (https://github.com/alibaba/async\_simple ), which created a separate branch for C++ Modules but didn't even merge it into the main branch.

https://github.com/infiniflow/infinity might be the first large-scale project that fully adopts C++ Modules. It is developed using Clang 17 or newer versions (such as the unreleased Clang 18) and requires the latest version of CMake (3.28). The project tried to use Clang 16 or GCC 13 but wasn't successful. Honestly speaking, the support for C++ Modules in compilers on the Linux platform is still not perfect. I've attached some usage details for reference:

For example:

https://github.com/infiniflow/infinity/blob/main/src/common/stl.cppm

This file demonstrates how to resolve various compilation errors caused by the lack of module support in the C++ standard library.

https://github.com/infiniflow/infinity/blob/main/src/common/third\_party.cppm

This file demonstrates how to incorporate other third-party dependencies that do not have module support into the project.

C++ Modules helped Infinity significantly reduce it compilation time: It brought its full compilation time from more than ten minutes to less than 5 minutes, and incremental compilation time to less than a minute. This is remarkable considering that the Linux project consists of around 200,000 lines of code and includes over a million lines of C++ code in its dependencies. For that project, C++ Modules have indeed alleviated the frustration of waiting for hours due to changes in header files in C++ development.

https://redd.it/18ti2fi
@r_cpp

Читать полностью…

C++ - Reddit

My Favorite C++ Pattern: X Macros
https://danilafe.com/blog/chapel_x_macros/

https://redd.it/18w728v
@r_cpp

Читать полностью…

C++ - Reddit

{fmt} 10.2 released with source_location and bitset support, chrono and path formatting improvements and more
https://github.com/fmtlib/fmt/releases/tag/10.2.0

https://redd.it/18w47g7
@r_cpp

Читать полностью…

C++ - Reddit

Sorting indirectly
https://tomhultonharrop.com/c++/sorting/2023/08/19/sorting-indirectly.html

https://redd.it/18uav0k
@r_cpp

Читать полностью…
Subscribe to a channel