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

Where's the unary dereference operator as a function object?

The title says it all, though a bit of context:

I personally find the use of existing function objects very useful for working with std::ranges. But frequently, if you have a range of pointers, the first step in working with the ranges is to pass the range to a std::views::transform to convert the range of pointers to a view of references. This would be much easier if I could just use something like std::views::transform(std::dereference{}).

The same argument could be made for the other member access operators, for example a range of indicies converted to a view of references using std::bind_front(subscript{}, vec)

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

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

C++ - Reddit

Do we have System Design interview rounds for CPP

I am a C++ developer having 3 years of experience. I am currently learning Low Level Designing in Java. Questions like Design TicTacToe, Parkinglot, BookMyShow etc. I am sure Java related interview have these rounds. But do C++ interview have these kinds of questions? I am going to make my first switch and have been practicing these in Java but wanted to know if I should also practice in CPP.

Some companies dont care about language. I am mostly looking into SDE roles. But am open to companies like Intel and IBM as Cpp dev.

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

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

C++ - Reddit

Question about opening a new window

keybdevent (VKLCONTROL, 0, KEYEVENTFEXTENDEDKEY, 0);
keybd
event (0x4e, 0, KEYEVENTFEXTENDEDKEY, 0);
Sleep (100) ;
keybd
event (0x4e, 0, KEYEVENTFKEYUP, 0); keybdevent (VKLCONTROL, 0, KEYEVENTFKEYUP, 0);
Sleep (10) ;
exit (1);

This is my first time using C++ to emulate keystrokes, and I got it to open a new window, but afterwards it seems like the CTRL key is stuck in a pressed state, Even though I said KEYUP to the LCONTROL key. I can’t figure this out for the life of me, any help would be greatly appreciate.

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

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

C++ - Reddit

Range Based For loops from Partial Containers

I have code like this, for some container v:

for (auto it1=v.begin(); it1!=v.end(); it1++)
for (auto it2=it1+1; it2!=v.end(); it2++)
for (auto it3=it2+1; it3!=v.end(); it3++) {
// use it1,it2,it3 triplets with no duplicates or repeats
}

How can I recast the for loops using modern range based for loops. For the outermost loop I can write:

for (auto elem1: v)

because I traverse the whole container. But how do I code the inner loops:

for (auto elem2: v-?)
for (auto elem3: v-??) {

​

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

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

C++ - Reddit

7 Reasons To Take CPP At 60
https://youtu.be/KaesziThK4g?si=IuR0Vr2Kft8q3jhO

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

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

C++ - Reddit

Who owns studyplan.dev?

Does anyone know who owns the website studyplan.dev?

It seems to have some good C++ tutorials, but no legal notice and whois just returns Contact Privacy Inc. Customer 7151571251.

Most tutorials seem to be written by a guy called Ryan McCombe.

In all other ways it looks like a scam website, all images are AI generated, it claims to have 16 thousand positive reviews and over 400 thousand people using it and wants people to register.

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

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

C++ - Reddit

constexpr and consteval functions
https://biowpn.github.io/bioweapon/2024/02/17/constexpr-consteval-function.html

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

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

C++ - Reddit

The latest C++ and C++-related videos on YouTube

In case you missed it, and you might have, https://www.swedencpp.se/videos is an always up to date list of the most recent C++ and C++ related videos for developers. (most recent is the last 30 days)

Conference videos are not on the list since conferences would hide all the content other developers and user groups create once a conference took place and releases the videos.

But a conference video listing might be added in the future.

I hope you like this little service for the C++ developer community and find it useful.

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

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

C++ - Reddit

Initial size of vector.

So, I was reading about vectors and the tutor said that vector is a dynamic size array, where size can grow and shrink as per the requirement. Even if you don't initialize a vector with size, it works. When the size is not initialized, an empty vector is created and when an element is pushed into it, a new vector of *SOME SIZE* is created and all the elements from the previous are copied to it. So, the question is like for the first element is it initialized with size 1 or some other number. I know that the new size is decided using some mathematical function but I am not sure about it. Can anyone please clarify these. And also, are vectors created inside heap using a pointer on the stack??

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

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

C++ - Reddit

Monitor variable changes in functions with Visual Studio extension
https://www.youtube.com/watch?v=5bfUWJYEQCw

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

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

C++ - Reddit

Trying to understand an example of variable lifetime

===> All questions are resolved. Thanks all !

Hi all, I was reading a cpp puzzle book by Jason Turner, and got a question about an example of variable lifetime. Here's the code. (I slightly modified the names, but the idea is the same)

void func() {
Type1 obj1("a", "b"); // a is printed
Tyep1 obj2("c", "d"); // c is printed
} // d is printed, obj2's lifetime ends first
// b is printed, obj
1's lifetime ends second

Q1: why the order of printed letters is "acdb", instead of "abcd"?

Q2: why obj_2 gets terminated first and then obj_1 gets terminated?

Thank you in advance!

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

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

C++ - Reddit

How to get good and what to do with c++

Hello everyone!
As you can read from the title, I'm really interested in picking up and getting good at c++. I'm not a newbie though. I started software engineering where I studied C++ as my first language, just the basics nothing advanced or even intermediate. 3 years ago I switched to computer science and I have done exams in C, java and should study prolog and ML soon. I'm also working as a junior Developer for a company building and maintaining web apps and websites written in .net framework (mainly 4.8) and some net core.
So as you can see I'm not a beginner and I have a basic understanding of data structures (linked lists, graphs, stacks, queues ,etc..) and OOP (java and python which Iearned by myself).
I was always fascinated by cpp though. The problem is that it seems so complicated that I have no idea what it means to "be good" at cpp, but I also don't really know how to use it and what doors could this knowledge open for me (since I don't plan on staying a web developer forever). So what I really wanted to ask you with this post is: what is your favourite use (and maybe which is the best overall) for C++? And what should I know to be actually GOOD at it?

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

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

C++ - Reddit

C++ Better Solution #1 : Container choice.
https://issamvb.medium.com/c-better-solution-1-container-choice-5d8afe126864

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

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

C++ - Reddit

What to do next

I started learning c++ about three months ago and have good understanding of the basics (data types, variables, conditionals, loops, arrays and pointers) and made lots of projects using these, but now I have no clue what to do next, as everything I learn now just doesn't seem like it makes sense or isn't useful. Can anyone help?

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

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

C++ - Reddit

What's New for C++ Developers in Visual Studio 2022 17.9
https://devblogs.microsoft.com/cppblog/whats-new-for-cpp-developers-in-visual-studio-2022-17-9/?WT.mc_id=academic-0000-abartolo

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

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

C++ - Reddit

What's current state of C++ adoption in GCC?

I've read an old article:

https://lwn.net/Articles/542457/

Back then they started transitioning to C++. How is it going now? What's the state? Any article/blog posts? I've search but haven't found.

Ofc I can go and see myself, but there are tons and tons of code, I can't asses that quickly.

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

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

C++ - Reddit

Global variable isnt changing in second thread

Hey guys,
i have a problem... Let me explain my situation first:
I run two different threads in my C/C++ (GCC/Vs Code on Linux) program.
One is a cyclic thread for communication with some embedded system and one is acyclic which is for handling user IO..
The acyclic one loads some data into an global array (char IO4096) and the cyclic thread sends and reads the data from this char array..
The timining(for send and receive) is about 1ms, and it takes the thread about 200 usec to send and receive the data.
My problem is, whenever i try to store some data into the array, it gets stored in the acyclic thread, but it doesnt get stored in the cyclic one.
I already tried making the array atomic, and i also tried mutexes. Didnt work..(maybe i used them wrong?)

BUT! If i use a while/for loop in the acyclic thread - with about 1000-2000 iterations - in which i try to store the data repeatingly, it works. Then the other thread can "see" the changed data in the array.
I probably have some data race? But shouldnt that have been solved when using mutexes?

On windows(msvc) it somehow works just fine?(even without mutexes)

Any help would be appreciated. Thanks in advance!

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

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

C++ - Reddit

C++ Program Synthesis

Hi all,

I am currently working on a personal project and I am looking to play around and incorporate some open source program synthesis tools. Something like CodeT5+. The issue is I was unable to find a good model for c++ and it produces largely unfunctional code when you ask for C++.

Any suggestions on open source code generation models I can use that are capable of putting out some solid C++ code?

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

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

C++ - Reddit

Is it possible to make a script that can detect if two specific drives are plugged in and backup all of the files from one of them to the other automatically?

I have an ssd that I keep ALL of my important files on, and an hdd that I backup all of the files to every week or so. Additionally I use version control for any programming projects. I'm wondering if I can make a script that can detect when the two drives are both plugged in, and when I run the script, have it copy everything from the ssd onto the hdd. It's kinda a pain to have to manually drag and drop files that I want to overwrite and any existing software I've tried is specific to one brand of drive, which doesn't work because my ssd is Samsung and my hdd is Seagate.

Is this doable? If yes, do I need to use the win32 api?

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

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

C++ - Reddit

Borrow Checker, Lifetimes and Destructor Arguments in C++
https://a10nw01f.github.io/post/advanced_compile_time_validation/

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

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

C++ - Reddit

Explore EFP: A Practical Functional Programming Library for C++

Introducing EFP, a header-only C++ library designed for functional programming enthusiasts. Originally developed for internal use at the robotics startup Ars Vivendi, EFP aims to provide C++ developers with a set of tools for efficient and expressive code, drawing on functional programming principles for improved safety with zero-cost performance.

Key Features:

\- Intuitive sequence operations with the Sequence trait.
\- Higher order functions with automatic allocation avoidance.
\- String as Vector<char>
\- Simple pattern matching via the Enum container.
\- Maybe<A> as Enum<Nothing, A>
\- String formatting, file IO, allocation free cyclic data container etc.


EFP is in beta, and we’re looking for feedback from the C++ community. Whether you’re exploring functional programming or searching for efficient coding patterns, your insights can help refine EFP for broader use.


Try EFP in your projects and share your experience with us on GitHub: https://github.com/cwahn/efp


Please join the effort to tailor EFP for practical, everyday C++ programming.

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

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

C++ - Reddit

BinaryRelations: Three new associative container classes
https://github.com/RonPieket/BinaryRelations

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

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

C++ - Reddit

Casting away volatility

Hi all,

I have a class that clients want to be volatile so I defined a volatile copy assignment operator but I'm having some difficulty defining comparison operators for my class not because of the logic but because all the comparison functions that are defined on the internal members of the class work on non-volatile parameters so Im getting errors about removing volatility. Since all I'm doing is comparing, is it okay to cast away volatility of said members using const_cast?

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

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

C++ - Reddit

CPP and AI

So i want to stick to cpp (can’t stand python and my realm i need to focus on is low level) but i want to learn AI. In order to build defense tools like Nightshade against AI, actually. Anyone know any good place to start learning this stuff in cpp? It all seems to be in python but wasn’t that llama 7B model written in cpp?

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

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

C++ - Reddit

VC++: Convert Console Project to Non-Console
https://www.codeproject.com/Tips/5376609/VCplusplus-Convert-Console-Project-to-Non-Console

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

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

C++ - Reddit

Coding Issue

I'm new to learning C++. I have an output file that isn't working properly. Is this an okay place to ask questions on my code?

&#x200B;

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

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

C++ - Reddit

WG21, aka C++ Standard Committee, February 2024 Mailing
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/#mailing2024-02

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

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

C++ - Reddit

Web Interface for IoT project

Hi all, I need help in my work. We have a project for IoT purposes and the code is written in C++. The services are then load into config.json file. Now I am to make a web based UI in react for the said project which controls the json files in the project and make changes to it for configurations. What do you think can be the possible solutions here ?

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

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

C++ - Reddit

Is it a bad habit to write c flavored cpp code?

I recently worked at a gaming company that uses cpp for their games. And one thing they noticed about me is that I write basically c look alike code in cpp, when they told me why you code like this I told them since I hate cpp syntax and cpp being fundamentally flawed I use basically c with classes. They said ok and I moved on. Now is it a bad habit to write c like cpp in a game engine or anything else

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

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

C++ - Reddit

C++03 tutorial

In my University the exams are based on c++03 verzión. I want to study ahead, do you guys have any recommended sources?

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

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