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

Latency-Sensitive Applications and the Memory Subsystem: Keeping the Data in the Cache - Johnny's Software Lab
https://johnnysswlab.com/latency-sensitive-applications-and-the-memory-subsystem-keeping-the-data-in-the-cache

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

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

C++ - Reddit

Seeking the guidance

Hello fellas,


I've completed a course of C++ and have got some understanding of it, for the next step I was thinking to learn algorithms and data structures, and maybe do some pet project.

The goal is to get employment in software development (since from what I saw it pays the best), preferably remotely.

I understand that getting a job and working on the actual project it the best way to grow, so my question would be, what's the path for employment? What else should I learn, GUI or some other language? Feels weird to do so, since I have not done any actual work with C++.


I do not know where to go and how to proceed, please help.

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

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

C++ - Reddit

Proving Immediate Mode GUI's are Performant
https://www.forrestthewoods.com/blog/proving-immediate-mode-guis-are-performant/

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

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

C++ - Reddit

Progress Report: Adopting Headers Units in Microsoft Word
https://www.youtube.com/live/H6GQUg5JquU?si=1iC_OvRQ_MprzDTQ&t=7389

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

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

C++ - Reddit

std::bitset::to_u(l)llong() noexcept

Hi,
I have a question regarding the std::bitset. Is there any arguments of not letting both its functions to_ulong() and to_ullong() to check the total amount of bits with a *requires* clause? In such case we could enable them conditionally only for those cases where they make sense and mark them as *noexcept* and remove them otherwise from the
pool of available functions.

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

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

C++ - Reddit

Logging functions vs macros?

I am getting really sick of no overload resolution with macros and it's tedious to add and maintain different logging macros throughout a project. I work with unreal engine so looking at the disassembly is difficult as well as looking at the exact compiler flags.


Generally from my tests of both clang and msvc, empty function bodies are stripped from the code.
The environment seems to be using `\\Ox` in development builds which would indeed strip the empty function calls (afaik).


So should I just move my logging code into templated nicely overloaded functions and just if/endif the bodies of the functions so it becomes what I assume to be a no-op in shipping builds?


I would really appreciate some thought's on this from some others.

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

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

C++ - Reddit

Optimizing C++ code to run 87x faster (One Billion Row Challenge)
https://simontoth.substack.com/p/daily-bite-of-c-optimizing-code-to

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

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

C++ - Reddit

C++ Videos Released This Month - April 2024 (Updated to Include Videos Released 04/22/2024 - 04/28/2024)

This month the following C++ videos have been published to YouTube. A new post will be made each week as more videos are released

CppCon

04/22/2024 - 04/28/2024

Lightning Talk: You Should Use AddressSanitizer - Brody Holden - [https://youtu.be/1RxMPEVBMJA](https://youtu.be/1RxMPEVBMJA)
Lightning Talk: Thread Safety With synchronized_value in C++ - Jørgen Fogh - https://youtu.be/F0jaGcCUpOo
Lightning Talk: Whitespace: A Humorous Short Talk - Dan Curran - [https://youtu.be/Kg3rw3KJbMk](https://youtu.be/t2H3-J2drvg)
Lightning Talk: The Responsibility of C++ - Neil Henderson - https://youtu.be/UokUnXfxjow
Lightning Talk: Higher-Order Template Metaprogramming with C++23 - Ed Catmur - [https://youtu.be/KENynEQoqCo](https://youtu.be/KENynEQoqCo)

04/15/2024 - 04/21/2024

Lightning Talk: Help! My Expression Template Type Names Are Too Long! - Braden Ganetsky - https://youtu.be/YKWBNzjmBvg
Lightning Talk: Spanny: Abusing C++ mdspan Is Within Arm’s Reach - Griswald Brooks - [https://youtu.be/FZZ3CDnBEx4](https://youtu.be/FZZ3CDnBEx4)
Lightning Talk: C++ and the Next Generation: How to Support Women and Families in Tech - Sara Boulé - https://youtu.be/t2H3-J2drvg
Lightning Talk: Filling the Bucket: Reading Code, C++ Code Interviews & Exams - Amir Kirsh - [https://youtu.be/ju189bWGNmY](https://youtu.be/ju189bWGNmY)
Lightning Talk: Write Valid C++ and Python in One File - Roth Michaels - https://youtu.be/GXwYjI9cJd0

04/08/2024 - 04/14/2024

Lightning Talk: The Power of Silence and Music in Agile Software - Valentina Ricupero - [https://youtu.be/cPKbQOEqAVU](https://youtu.be/cPKbQOEqAVU)
Lightning Talk: ClangFormat Is Not It - Anastasia Kazakova - https://youtu.be/NnQraMtpvws
Lightning Talk: A Fast, Concurrent Data Loader for Time-Series Data - Glenn Philen - [https://youtu.be/rsERMD9jUNE](https://youtu.be/rsERMD9jUNE)
Lightning Talk: Un-Undefining Undefined Behavior in C++ - Jefferson Carpenter - https://youtu.be/S49fKs0Bv1Q
Lightning Talk: Interfaces in C++ - Megh Parikh - [https://youtu.be/zPudH\_y4OXo](https://youtu.be/zPudH_y4OXo)

04/01/2024 - 04/07/2024

Lightning Talk: Implementing Coroutines Using C++17 - Alon Wolf - https://youtu.be/ULJcnSTwg9g
Lightning Talk: Introverts: Speak! - Rudyard Merriam - [https://youtu.be/EvDh19wWDOo](https://youtu.be/EvDh19wWDOo)
Lightning Talk: Constraining Automated Trading Risk with Linux Signals - Max Huddleston - https://youtu.be/\_HGQ\_8cr0sY
Great C++ is\_trivial: trivial type traits - Jason Turner - [https://youtu.be/bpF1LKQBgBQ](https://youtu.be/bpF1LKQBgBQ)
Better CMake: A World Tour of Build Systems - Better C++ Builds - Damien Buhl & Antonio Di Stefano - https://youtu.be/Sh3uayB9kHs

All of these talks can also be accessed at https://cppcon.programmingarchive.com where you can also find information on how to get early access to the rest of the CppCon 2023 lightning talks.

Audio Developer Conference

04/22/2024 - 04/28/2024

A More Intuitive Approach to Optimising Audio DSP Code - Gustav Andersson - [https://youtu.be/HdyiQLQCvfs](https://youtu.be/HdyiQLQCvfs)
AudioworX: A Framework for Streamlining Development of Audio Post Processing for Car Audio Systems - Ravish Sreepada Hegde & Harish Venkatesan - https://youtu.be/TuAJPo3GrmI
Music Rendering in Unreal Engine: The Harmonix Music Plugin for MetaSounds - Buzz Burrowes - [https://youtu.be/ImOsjSDBWZY](https://youtu.be/ImOsjSDBWZY)

04/15/2024 - 04/21/2024

Making It Good (the Principles of Testing Hardware and Software) - Emma Fitzmaurice -

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

C++ - Reddit

Introduction to Flow-IPC: Open Source Toolkit for Low-Latency Inter-Process Communication in C++
https://www.linode.com/blog/open-source/flow-ipc-introduction-low-latency-cpp-toolkit/

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

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

C++ - Reddit

C++ Question

Hello, I have a question about c++ that I can solve with Qt. but unfortunately I can't be successful until now.



can I ask my question here to solve it?

Many thanks in advance

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

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

C++ - Reddit

what are the advantages of non-member functions over static member-functions?

In Stroustroup's paper: "Why C++ is not just an Object-Oriented Programming Language"
He expresses the benefit of using namespaces to group classes with functions that do not need access to the direct internals:

>...C++ provides namespaces for grouping declarations [Stroustrup,1994\]. For example, many operations on Dates shouldn’t be members of class Date because they don’t need direct access to the representation of a Date. Providing such functions as non-member functions leads to a cleaner Date class, but we would still like to make the association between the functions and the class explicit:

namespace Chrono {

// facilities for dealing with time:

enum Month {
// ...
};

class Date {
// ...
};

int diff(Date a, Date b);
bool leapyear(int y);
Date nextweekday(Date d);
Date next
saturday(Date d);

// ...

}

That makes perfect sense to me. However, I wonder what the advantages are of not using static member functions of the date class, specifically for "diff", "next_weekday" and "next_saturday". Is this simply a matter of taste? What are your thoughts?

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

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

C++ - Reddit

Do you use text editor or IDE? (2024 poll)

And which one?

View Poll

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

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

C++ - Reddit

Looking for feedback - ML framework API

I am working on ML framework and currently I am working on a new test case (so this "model" is bogus) and realized that core API (model setup and invocation) have not changed in awhile.

How easy is this to read if one is not familiar with the overall framework?

using std::string_view_literals::operator""sv;

struct CharToVector {
using input_t = char;
using output_t = Vector<float, 'z' - 'a' + 1>;

output_t operator()(char c) const { return output_t::OneHot(c - 'a'); }
};

constexpr Model kModel = Model<CharToVector>() | layers::Linear<5> |
layers::Linear<10> |
layers::Categories(std::array{"Beep"sv, "Boop"sv});

TEST(ArenaTest, Basic) {
ModelParameters parameters = RandomParameters(&kModel, -1, 1, 42);
EXPECT_EQ(kModel('c', parameters), "Boop");
}


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

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

C++ - Reddit

StockholmCpp 0x2E, Intro, event host presentation, C++ news and a coding quiz
https://youtu.be/xnNufsMvum4

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

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

C++ - Reddit

Seeking Guidance for Contributing to Open-Source C/C++ Projects

I am a software engineer with three years of experience, and I've been working as a C++ developer for the past six months. I'd like to contribute to open-source C++ projects, but I have no experience with open-source contributions. Additionally, many open-source projects are quite large, and I find them difficult to understand. My question is: how can I contribute to open-source C/C++ projects?

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

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

C++ - Reddit

Learning c++

What’s the most update, go at your own speed course/book/series that can help me begin to learn to program with C++?

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

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

C++ - Reddit

Preventing -$version suffix on LLVM files from official LLVM repos.

I'm trying to use the official LLVM repos in my CI and my biggest problem is that most (all?) binaries are suffixed with -$version. This causes problems with specifying those binaries in generic scripts and CI-like environments. The problem is manageable for only compiler, but when you start using llvm-cov and llvm-profdata for coverage and then other stuff for other tools, things become too messy very soon.

Is there a good way to deal with this situation? My proposed solution is extremely clunky, by essentially finding out which files were installed by those packages and have -18 as suffix and then using update alternatives on them in Ubuntu. I would appreciate it if someone has a better solution.

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

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

C++ - Reddit

OOP Inquiry

Hey, I'm new to programming and started my journey with cpp, i was practicing oop by making bank system and I'm using txt files as data base for clients, employees and administrators

My logic is when i create a new client in the constructor it invokes a method called saveClientsInfo(*this)

And the client information will be saved in the file automatically, is this way go against any principles of OOP??

It runs okay but i wanna deep my understanding of how to do things the right way not just make it works.

***** the client constructor code ******


lient::Client(string name, string password, double balance) {


// sending the attributes to inherited setters in person class
Client::set_name(name);
Client:: set_password(password);

// not inherited
Client::set_balance(balance);

id = FilesHelper::GetLast("Clientlastid.txt");

FilesHelper::SaveClientInfo(*this);

}


////////////

Thank you.

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

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

C++ - Reddit

Understand internals of std::expected
https://www.cppstories.com/2024/expected-cpp23-internals/

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

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

C++ - Reddit

How To Use Skia Shader SkSL Shading Language Code in C++ Builder?
https://learncplusplus.org/how-to-use-skia-shader-sksl-shading-language-code-in-c-builder/

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

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

C++ - Reddit

Typed reflection and meta-programming

Hi everyone,

In the past 2 years it has been my job to work on a compile-time reflection and meta-programming prototype under the supervision of u/jfalcou.

We've recently opened access to the compiler online, and published a few use-cases driven articles to explain the design.

You can find the articles here :

Introduction

Member functions generation

Symbolic differentiation


And access the compiler here : https://cppmeta.codereckons.com

We're hoping to spark interest and are eager to gather feedback or questions :)

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

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

C++ - Reddit

https://youtu.be/TYXPLdN7awA
Confluence of Code and Classical Music: Ragas, Bach & Sonic Pi - Nanditi Khilnani - [https://youtu.be/DCYM5\_VjC4Y](https://youtu.be/DCYM5_VjC4Y)

04/08/2024 - 04/14/2024

Real-Time Inference of Neural Networks: A Guide for DSP Engineers - Valentin Ackva & Fares Schulz - https://youtu.be/z\_RKgHU59r0
Modular Audio Synthesis on FPGAs With the High Level Synthesis Development Flow - Aman Jagwani - [https://youtu.be/gAZGuwggAQA](https://youtu.be/gAZGuwggAQA)
Reactive Embedded Programming - Tom Waldron - https://youtu.be/FUX4os7QZgc

04/01/2024 - 04/07/2024

Build a High Performance Audio App With a Web GUI & C++ Audio Engine - Colin Sullivan & Kevin Dixon - [https://youtu.be/xXPT8GAEozs](https://youtu.be/xXPT8GAEozs)
Procedural Sound Design Applications - From Embedded to Games - Aaron Myles Pereira - https://youtu.be/Da6mDLrOGok
Embedded Software Development - A Wild Ride! - Matt Speed & Andy Normington - [https://youtu.be/xr8fSJ2Uw1A](https://youtu.be/xr8fSJ2Uw1A)

Meeting C++

04/01/2024 - 04/07/2024

C++20's Coroutines for Beginners - Andreas Fertig - https://www.youtube.com/watch?v=0iiUCuRWz10

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

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

C++ - Reddit

Pure Virtual C++ 2024 is Tomorrow
https://devblogs.microsoft.com/cppblog/pure-virtual-c-2024-is-tomorrow/

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

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

C++ - Reddit

GCC 14 twice as slow as GCC 13?

Ubuntu 24.04 has GCC 14, and on our CI, it takes twice as long to compile the same Boost tests as GCC 13, other things being equal. At first we thought there was something wrong with Ubuntu's GCC 14 (as it's not officially out yet), but a freshly compiled GCC 14 from source seems to give the same result.

Anyone else seen this, or know something about it? 2x slowdown seems like a noticeable regression.

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

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

C++ - Reddit

C++20 Hardware accelerated perfect hashing

Some fun with hardware accelerated perfect hashing for compile-time keys.

Use case: Given a list of N keys (known at compile-time) find a perfect hash - https://en.wikipedia.org/wiki/Perfecthashfunction.

Code -> https://github.com/boost-ext/mph

ATM, the code requires C++20 and BMI2 - https://en.wikipedia.org/wiki/X86Bitmanipulationinstructionset (Intel Haswell+, AMD Zen3+) support and it's focused on run-time execution performance.

Works best for less than 256 key/value pairs and supports strings (up to 8 characters) and integers (up to uint64t).
Compilations times are driven by the number of key/value pairs and the constexpr mask lookup.

More info, how it works and limitations ->
https://github.com/boost-ext/mph#faq

Performance ->
https://github.com/boost-ext/mph#performance

Benchmarks and how it compares to gperf/etc. ->
https://github.com/boost-ext/mph#benchmarks (Don't trust, always measure!)

Examples:

int main(int argc, char**)
constexpr std::array ids{
pair( 54u, 91u),
pair(324u, 54u),
pair( 64u, 324u),
pair(234u, 64u),
pair( 91u, 234u),
};

static
assert(0u == mph::hash<ids>(0u));
staticassert(91u == mph::hash<ids>(54u));
static
assert(54u == mph::hash<ids>(324u));
staticassert(324u == mph::hash<ids>(64u));
static
assert(64u == mph::hash<ids>(234u));
staticassert(234u == mph::hash<ids>(91u));

return mph::hash<ids>(argc);
}

main(int): // g++ -DNDEBUG -std=c++20 -O3 -march=skylake
movl $7, %edx
xorl %eax, %eax
pext %edx, %edi, %edx
movl %edx, %edx
cmpl %edi, lut(,%rdx,8)
cmove lut+4(,%rdx,8), %eax
ret

lut:
.long 64
.long 324
.zero 8
.long 234
.long 64
.long 91
.long 234
.long 324
.long 54
.zero 8
.long 54
.long 91
.zero 8

Full example ->
https://godbolt.org/z/nvf4xbMea

int main(int, const char** argv) {
constexpr std::array symbols{
pair("BTC", 1),
pair("ETH", 2),
pair("BNB", 3),
pair("SOL", 4),
pair("XRP", 5),
pair("DOGE", 6),
pair("TON", 7),
pair("ADA", 8),
pair("SHIB", 9),
pair("AVAX", 10),
pair("LINK", 11),
pair("BCH", 12),
};

return mph::hash<symbols>(
std::span<const char, 4>(argv[1], argv[1]+4)
);
}

main: // g++ -DNDEBUG -std=c++20 -O3 -march=skylake
movq 8(%rsi), %rax
movl $789, %ecx
leaq lut(%rip), %rdx
xorl %esi, %esi
movl (%rax), %eax
pextl %ecx, %eax, %ecx
cmpl (%rdx,%rcx,8), %eax
movzbl 4(%rdx,%rcx,8), %eax
cmovnel %esi, %eax
retq

lut: ...

Full example ->
https://godbolt.org/z/P6TWM4P7c

Additionally there are following options for hash call

- policy (how to do the final comparison) - conditional, unconditional (unsafe), likely, unlikely, conditional
probablity, unpredictable (clang)
- alignment - whether to align the underlying lookup table (by default no alignment options are set)

Library -> https://github.com/boost-ext/mph
Updates -> https://twitter.com/krisjusiak/status/1784651961830187470

By no means it's ideal, though it and works pretty well.

Very interested in ideas for improvements regarding run-time execution and/or compilation times (might be unsafe) as well as other ideas as the space is huge and there is vast research in that area.

Work is based on many, many great resources which can be found at https://github.com/boost-ext/mph#acknowledgments. Thanks!

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

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

C++ - Reddit

Speeding Up C++ Build Times | Figma Blog
https://www.figma.com/blog/speeding-up-build-times/

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

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

C++ - Reddit

Is it good to start with Ncurses?

Hey!
Just wanted to share—I've recently wrapped up the basics of C++! As I started poking around some mini projects to get a better feel for coding, I noticed a bunch of them using <window.h> and <coin.h>. But here's the kicker—I'm running Linux, and those libraries aren't available to me.
So, I reached out to ChatGPT for advice, and it suggested I give NCurses a shot for creating Terminal User Interface (TUI) applications. Now, I'm wondering: Is NCurses a good place for a beginner like me to start, or do you have any other recommendations?

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

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

C++ - Reddit

I understand many principles, but i have trouble putting them to practice/finding projects to practice with.

Any good beginner projects to practice on? I know about codewars, is that a good place to get better?

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

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

C++ - Reddit

Mobile apps in C++

Why is it not possible to write a mobile app (android or ios) COMPLETELY in c++.

Please don't tell me flutter, xamarin, react native etc are more effective and easier. I know all about those frameworks and I have used a some if not all of them.

Please contribute only if you have any useful info as to why we can write a mobile app entirely in c++ or if you know any tools that allows writing mobile apps entirely with c++

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

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

C++ - Reddit

envrionment for cpp on WSL2

Hi everyone !

I'm on WSL2 ubuntu to be exact and I want to know for those who are in WSL2 what is your setup to code in cpp. I'm planning to make a large project and not only a hello world output lol So if you have recommendations for a good environment let me know !

Current setup : vscode + gcc but I'm open to anything

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

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