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

Making 'using' more useful and safer by limiting its effect

Hi everyone. For some time I've been wondering if there's a way to improve C++ code readability by making one of the worst beginner practices actually good. We all wanted to spare some keys by avoiding all the `std::` in our code at some point, but what if you could do that without making your headers dangerous, code unpredictable, and still retaining the same level of explicitness?

I wrote the idea for a proposal here:
https://github.com/LMauricius/cpp-ideas/blob/master/limited\_using.md

It's not yet ready for a proposal, as I've never written anything like that. So for now, let's discuss!

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

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

C++ - Reddit

Problem with debugging in VSCODE

Hey there,

I have started learning C++ a week ago, but it's been a struggle to use VSCode to debug my code ever since I started dealing with arrays. It won't show which elements an array have at "Variables" tab and it always seems to be kind of wanky to debug...


Is it supposed to be like that or I am using the wrong extensions and settings to run it properly?

Thanks in advance! Appreciate the help!

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

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

C++ - Reddit

The Modern C++ STL
https://youtu.be/p0IC16BYe84?si=UyBl5SQiEwXz4jQl

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

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

C++ - Reddit

Introduction to Collision Detection (C++ based)
https://youtu.be/KZJXb5AF6NM?si=e7y8_TpsrD0yC8ax

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

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

C++ - Reddit

C++ or Frontend first?

Hi all,

I'm a 24yo with (very) entry level knowledge of HTML, CSS, and Python.

I coded for a few months as a hobby a few years back before Uni got the front seat in my schedule again.

I went back to HTML and CSS just to dip my toe, and have decided this is a nice hobby I would like to develop.

The holy grail project I have in mind is (to put it very briefly) a super secure file storage and sharing platform which I hope to (but don't have to) be able to sell one day in however many years time.

I chose C++ as my first 'real' language as I've heard how efficient it is, and how well it performs with time crucial tasks, as well as databases.

The question is, should I dive headfirst into C++, get a good grip on that, and then work on JS and polishing up frontend skills, or do you recomment going the other way around?

Other opinions also welcome!

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

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

C++ - Reddit

Contracts for C++ - Timur Doumler - ACCU 2025
https://www.youtube.com/watch?v=u73ZB_vml_c

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

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

C++ - Reddit

Build Tools for c/c++ development on windows

If someone is interested of c/c++ development exclusively on windows 11 with cl.exe in VS 2022 Community, what is the best or more widely used toolchain?

MSBuild + ... or CMake with Ninja ?

I will use C and C++ only for personal projects. I also like to use or copy parts from open source projects.

The main language I am using is Rust, but I want to study the win32 api and various other apis that would be interesting from the point of view of Rust projects.

Thank you so much in advance.


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

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

C++ - Reddit

Is LLVM libc good enough for desktop usage?

Hi, currently I build libcxx and statically link it for all desktop platforms, this ensures that I have the same cxx features everywhere.

I would like to have that with llvm-libc too, basically build llvm-libc then build llvm-libcxx on top of it to have the same consistency for C. Because at least %60 percent of libraries I use are C libraries.

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

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

C++ - Reddit

Spore-meta, a compile-time reflection library

Hello, I've developed a compile-time reflection library for C++23, while waiting for a more widespread implementation of P2996. It was initially developed for my engine to support serialization, scripting, automatic editor widget creation and more! Let me know what you think!

spore-meta is a C++23, header-only library to define compile-time reflection metadata for any given type. The library is optionally integrated with spore-codegen to automatically generate the reflection metadata via libclang and with CMake to run the code generation automatically when building a target.

EDIT: Forgot links!

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

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

C++ - Reddit

Beman Project new blog post - “About Beman” by Dave Abrahams!

Check out our first Beman Project blog post: “About Beman” by Dave Abrahams!

https://bemanproject.org/blog/about-beman/


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

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

C++ - Reddit

fargo - I built a Cargo-inspired build tool / scaffolding for C++ (zero-config project setup)

Hey all. I created a lightweight C++ project scaffolding and build tool that brings Rust's Cargo simplicity to C++ development. I had some help from Copilot, and I created it based on my needs, and I thought maybe someone will find it useful/interesting.

What it does:

Zero-config project setup \- `fargo new myapp` creates a complete C++ project with CMake, GoogleTest, benchmarks, and documentation ready to go
Cargo-like commands \- fargo buildfargo runfargo testfargo benchfargo check (static analysis), fargo format
Configuration profiles \- Different build settings for dev/release/CI environments
Integrated toolchain \- Built-in support for sanitizers (ASAN/TSAN), clang-tidy, cppcheck, Doxygen docs

Some example commands:

fargo new calculator
cd calculator
fargo run
fargo test
fargo bench
fargo check

It's a single bash script (\~1200 lines) that works on Linux/macOS.

GitHub: https://github.com/stelro/fargo

Would love to hear your thoughts or suggestions!

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

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

C++ - Reddit

32));
}
else if (id < 64) {
_id49_64 &= ~(1 << (id - 48));
}
else if (id < 96) {
_id65_96 &= ~(1 << (id - 64));
}
else if (id < 128) {
_id97_128 &= ~(1 << (id - 96));
}
else if (id < 160) {
_id129_160 &= ~(1 << (id - 128));
}
else if (id < 192) {
_id161_192 &= ~(1 << (id - 160));
}
else if (id < 200) {
_id193_200 &= ~(1 << (id - 192));
}
AnyMonitored = _id1_16 > 0 || _id17_32 > 0 || _id33_48 > 0 || _id49_64 > 0
|| _id65_96 > 0 || _id97_128 > 0 || _id129_160 > 0 || _id161_192 > 0 || _id193_200 > 0;
}

void ApplyMask(uint8_t id, int inputMask, bool startMonitoring) {
uint16_t _mask = inputMask & _2BYTE_MASK;

if (id == 1) { // 1-16 Optimized
_id1_16 = startMonitoring ? _id1_16 | _mask : _id1_16 & ~_mask;
}
else if (id == 17) { // 17-32 Optimized
_id17_32 = startMonitoring ? _id17_32 | _mask : _id17_32 & ~_mask;
}
else if (id == 33) { // 33-48 Optimized
_id33_48 = startMonitoring ? _id33_48 | _mask : _id33_48 & ~_mask;
}
else if (id == 49) { // 49-64 Optimized
_id49_64 = startMonitoring ? _id49_64 | _mask : _id49_64 & ~_mask;
}
else if (id > 0 && id < MAX_NUM_EXTENDED_GRIPPER) {
// value split across 2 lower masks or in higher range
id = id - 1; // convert to 0-index

uint8_t bits;
if (id < 16) { // 1-16
bits = id;
_id1_16 = startMonitoring ? _id1_16 | (_mask << bits) : _id1_16 & ~(_mask << bits);
_id17_32 = startMonitoring ? _id17_32 | (_mask >> bits) : _id17_32 & ~(_mask >> bits);
}
else if (id < 32) { // 17-32
bits = 16 - id;
_id17_32 = startMonitoring ? _id17_32 | (_mask << bits) : _id17_32 & ~(_mask << bits);
_id33_48 = startMonitoring ? _id33_48 | (_mask >> bits) : _id33_48 & ~(_mask >> bits);
}
else if (id < 48) { // 33-48
bits = 32 - id;
_id33_48 = startMonitoring ? _id33_48 | (_mask << bits) : _id33_48 & ~(_mask << bits);
_id49_64 = startMonitoring ? _id49_64 | (_mask >> bits) : _id49_64 & ~(_mask >> bits);
}
else {
// anything that requires a 32-bit mask
uint32_t _mask32 = _mask;
if (id < 64) { // 49-64 ( 16 bit storage)
bits = 48 - id;
_id49_64 = startMonitoring ? _id49_64 | (_mask << bits) : _id49_64 & ~(_mask << bits);
if (bits > 8)
_id65_96 = startMonitoring ? _id65_96 | (_mask32 >> bits) : _id65_96 & ~(_mask32 >> bits);
}
else if (id < 96) { // 65-96 (32 bit storage)
bits = 64 - id;
_id65_96 = startMonitoring ? _id65_96 | (_mask32 << bits) : _id65_96 & ~(_mask32 << bits);
if (bits > 16)
_id97_128 = startMonitoring ? _id97_128 | (_mask32 >> bits) : _id97_128 & ~(_mask32 >> bits);
}
else if (id < 128) { // 97-128
bits = 96 - id;
_id97_128 = startMonitoring ? _id97_128 | (_mask32 << bits) : _id97_128 & ~(_mask32 << bits);
if (bits > 16)
_id129_160 = startMonitoring ? _id129_160 | (_mask32 >> bits) : _id129_160 & ~(_mask32 >> bits);
}
else if (id < 160) { // 129-160
bits = 128 - id;
_id129_160 = startMonitoring ? _id129_160 | (_mask32 << bits) : _id129_160 & ~(_mask32 << bits);
if (bits > 16)
_id161_192 = startMonitoring ? _id161_192 | (_mask32 >> bits) : _id161_192 & ~(_mask32 >> bits);
}
else if (id < 192) { // 129-196
bits = 160 - id;
_id161_192 = startMonitoring ? _id161_192 | (_mask32 << bits) : _id161_192 & ~(_mask32 << bits);
if (bits > 16)
_id193_200 = startMonitoring ? _id193_200 | (_1BYTE_MASK & (_mask32 >> bits)) : _id193_200 & ~(_1BYTE_MASK & (_mask32 >> bits));
}
else if (id < 200) {
bits = 200 - id;
_id193_200 = startMonitoring ? _id193_200 | (_1BYTE_MASK & (_mask << bits)) : _id193_200 & ~(_1BYTE_MASK & (_mask << bits));
}
else {
// invalid input
sgImportedFunctions.pOperating->SendUserError(USER_ERROR_211, 1, WtUserFunctionOperating::HGMODE_MANUAL, false);
}
}
}
AnyMonitored = _id1_16 > 0 || _id17_32 > 0 || _id33_48 > 0 || _id49_64 > 0
|| _id65_96 > 0 || _id97_128 > 0 || _id129_160 > 0 || _id161_192 > 0 || _id193_200 > 0;

}

void RunMonitoring()

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

C++ - Reddit

constixel

https://github.com/tinic/constixel – A single-header C++20 2D graphics library that supports consteval/constexpr rendering and can output sixel or png data to a (supported) terminal.



Minimal memory use, no dynamic allocations, palette and 24/32-bit buffers, simple drawing ops, UTF-8 text and a zero-dep PNG encoder. Applications: embedded UI rendering, graphics over remote connections, unit tests, debugging etc; in the future compile-time visualizations should also be possible.



The scope of the library is limited and opinionated, primarily due to the sixel format limitations, so do not expect to use this for generic graphics rendering. There are way better options for that like canvas_ity. But if you need quick and easy graphical output directly in your terminal this could be an option.

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

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

C++ - Reddit

Is Central Dependency Management safe?

Languages like C and C++ do not have this feature and it is looked upon as a negative. Using a command line tool like pip and cargo is indeed nice to download and install dependencies. But I am wondering how safe this is considering two things.

1. The news that we are seeing time and again of how the npm, golang and python's central repositories are being poisoned by malicious actors. Haven't heard this happening in the Rust world so far, but I guess it is a matter of time.
2. What if the developer is from a country such as Russia or from a country that the US could sanction in the future, and they lose the ability to this central repository because the US and EU has blocked it? I understand such repositories could be mirrored. But it is not an ideal solution.

What are your thoughts on this? Should languages that are being used for building critical infrastructure not have a central dependency management? I am just trying to understand.

Edit: Just want to add that I am not a fan of Rust downloading too many dependencies even for small programs.

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

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

C++ - Reddit

sfl-library
https://github.com/slavenf/sfl-library

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

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

C++ - Reddit

What will be the solution of this question ?

I found this in CodinGame Clash of code and have been struggling with it.

The game mode is REVERSE : You do not have access to the statement. You have to guess what to do by observing the following set of tests:
01 Test 1
    Input
        CodinGame
    Expected output
        cOdInGaMe

02 Test 2
    Input
        IYouHeIs
    Expected output
        IyOuHeIs

03 Test 3
    Input
        quitJOKINGgetSERIOUS
    Expected output
        QuItJoKiNgGeTsErIoUs

04 Test 4
    Input
        kjhkshuuiuhlkrgthhkugsuhkdjfksjhgdfkjghkjskjk
    Expected output
        kJhKsHuUiUhLkRgThHkUgSuHkDjFkSjHgDfKjGhKjSkJk





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

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

C++ - Reddit

The Beman Project: Bringing C++ Standard Libraries to the Next Level” - David Sankel - CppCon 2024

Although it was published a few months ago, we invite you to revisit this great CppCon 2024 presentation by one of the Beman Project leads:
🎥 “The Beman Project: Bringing C++ Standard Libraries to the Next Level”
by David Sankel

📖 Watch the full talk and read the blog post: https://bemanproject.org/blog/beman-tutorial

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

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

C++ - Reddit

"Individual programmers do not own the software they write"

On "Embedded C Coding Standard" by Michael Barr

https://barrgroup.com/sites/default/files/barr\_c\_coding\_standard\_2018.pdf

the first Guiding principle is:

>1. Individual programmers do not own the software they write. All software development is work for hire for an employer or a client and, thus, the end product should be constructed in a workmanlike manner.

Could you comment why this was added as a guiding principle and what that could mean?

I was trying to look back on my past work context and try find a situation that this principle was missed by anyone.

Is this a case that someone developing software for a company my think they can do whatever they want with the software/source code? Is there any situation on your companies that happened something that this principle was not take in account?

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

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

C++ - Reddit

Is cppcon worth attending as a student?

Hi all, my school will partially cover the $350 attendance fee and I really want to go, but before confirming I wanted to check and see how worth it you guys think it is? Mostly because housing will cost a lot.

I use C++ for most of my programming and I am aiming for C++ related internships next year (currently using C at Amazon). The talks look cool, and meeting all the other C++ enthusiasts would be really fun and probably good career-wise.

Could anyone who’s been advise me on how worth it? Travel isn’t bad (coming from Chicago) and I’d split housing with my friend who’s going.

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

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

C++ - Reddit

SFINAE question

std::any provides the following two constructors:

(1) any( any&& other ) noexcept;

(2) template< class ValueType >
any( ValueType&& value );

The standard says that the second form "...participates in overload resolution only if std::decayt<ValueType> is not the same type as any..."

My question is, what is the purpose of making that distinction here? If what you pass is an any, the first choice will be selected anyway. If you pass anything else, the second choice will be selected.

Whats the point of using enable
if in this case? (example from boost)

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

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

C++ - Reddit

Cross-platform C++ build system suitable for personal use and small teams at work

Posting this in the hope someone finds it useful

* [https://gitlab.com/tonygould/cppbuildexample/-/blob/main/README.md](https://gitlab.com/tonygould/cppbuildexample/-/blob/main/README.md)
* [https://gitlab.com/tonygould/cppbuildexample/-/blob/main/docker/WSLAndDocker.md](https://gitlab.com/tonygould/cppbuildexample/-/blob/main/docker/WSLAndDocker.md) for building on linux using Docker containers -- instructions here are for WSL in Windows, but Docker will also work on Mac, and on native linux, of course!
* [https://gitlab.com/tonygould/cppbuildexample/-/blob/main/presentation/GettingStartedBuildingCpp.pdf](https://gitlab.com/tonygould/cppbuildexample/-/blob/main/presentation/GettingStartedBuildingCpp.pdf) for a presentation I did at the end of March


Motivation is that I've been using C++ a *very* long time, like the language and the people a lot, and kinda disappointed it can be hard to get started compared to Python and some other upstart languages with package managers we won't mention :'). Intention for this project is for beginners to be able to copy and paste and edit the project and have something working.

There are for sure some compromises that wouldn't work well for a large enterprise, especially if you had multiple inter-dependent projects. However it can be used as a build system for a small team with upto about a few hundred thousand lines of code -- requires a bunch of Jenkins (or other CICD) work, and the approach I suggest here of using essentially the same Docker image to host both dev containers and CICD containers can certainly work well in a modern devops environment.

I'm \_not\_ trying to say that developers should use CMake, vcpkg for dependencies, or even pybind for Python bindings (although I do love pybind). There are many ways to cut the cake and there is enough for us all to eat. I was touched a few months after the presentation I did that a stranger approached me and said they'd found it useful; hopefully someone else will.

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

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

C++ - Reddit

What's your opinion on header-only libraries

Do u prefer them to the libraries u have to link? Is the slowness in compile time worth it not having to deal with linking?

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

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

C++ - Reddit

🚀 Update: conjure_enum v1.2.0 - a C++20 enum and typename reflection Library

We're pleased to announce an update release of v1.2.0 of [`conjure_enum`](https://github.com/fix8mt/conjure_enum), a lightweight header-only C++20. This release adds improvements and changes, including some from user feedback.

* update cmake build, add options
* update API including more C++20 `for_each`, `for_each_n`, `dispatch`
* update `enum_bitset` ctor, using `std::initializer_list`
* added `starts_from_zero`
* updated and extended unit tests, srcloc tests
* update documentation
* fixed `std::ostream` missing error

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

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

C++ - Reddit

Weird C++ trivia

Today I found out that a[i] is not strictly equal to *(a + i) (where a is a C Style array) and I was surprised because it was so intuitive to me that it is equal to it because of i[a] syntax.

and apparently not because a[i] gives an rvalue when a is an rvalue reference to an array while *(a + i) always give an lvalue where a was an lvalue or an rvalue.


This also means that std::array is not a drop in replacement for C arrays I am so disappointed and my day is ruined. Time to add operator rvalue overload to std::array.


any other weird useless trivia you guys have?



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

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

C++ - Reddit

How to safely average two doubles?

Considering all possible pathological edge cases, and caring for nothing but correctness, how can I find the best double precision representation of the arithmetic average of two double precision variables, without invoking any UB?

Is it possible to do this while staying in double precision in a platform independent way?

Is it possible to do this without resorting to an arbitrary precision library (or similar)?

Given the complexity of floating point arithmetic, this has been a surprisingly difficult question to answer, and I think is nuanced enough to warrant a healthy discussion here instead of cpp_questions.

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

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

C++ - Reddit

{

// Monitor 1-64
if (_id1_16 > 0) Monitor16(0, _id1_16);
if (_id17_32 > 0) Monitor16(16, _id17_32);
if (_id33_48 > 0) Monitor16(32, _id33_48);
if (_id49_64 > 0) Monitor16(48, _id49_64);

// Monitor 65+
if (_id65_96 > 0) Monitor32(64, _id65_96);
if (_id97_128 > 0) Monitor32(96, _id97_128);
if (_id129_160 > 0) Monitor32(128, _id129_160);
if (_id161_192 > 0) Monitor32(160, _id161_192);

if (_id193_200 > 0) Monitor08(196, _id193_200);
}
};
```

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

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

C++ - Reddit

Bitmask storage and optimization in hot path

Hello everyone, I want some opinions of people much more experience than myself on how I should be optimizing a bit of code that I’m working on.

As the title suggests, I have the need to store and evaluate bit masks in a very hot(realtime) thread.

There are three sets of masks that I need to store. And the system only supports 32 bits (it is a micro computer).
- The first set of masks has a total of 64 bits. I have opted to use 4 uint16 for the storage, because the function that will be used to update the mask occasionally(maybe twice every 30 seconds) accepts a starting bit and a 16 bit mask.
- The second set has a total of 200 bits and the function that sets these bits has the same parameters.
- The third set has 250 bits, the same parameters, but will be used much less often. For simplicity of code I’ve used 32 bit storage here.

The hot path in question evaluates each mask and if a bit is true, perform a piece of logic against some API. I cannot use bitset here because iterating across the set times out the thread.


Now, ChatGPT is recommending I use an array of the uints of the desired size for storage. I opted for fields because these are known amounts and likely won't change in the future.

My question here is, what would you recommend for such a problem?

TLDR of code for hot path (full implementation below)
```
If (field >0) Evaluate(field);
```
Where evaluate iterates across the mask using a for loop and decides to do work or not.


edit: formatting & code:

```
class Monitor {
private:
uint16_t _id1_16, _id17_32, _id33_48, _id49_64; // most likely case use uint16 for optimization
uint32_t _id65_96, _id97_128, _id129_160, _id161_192; // 32 bit storage for 65-192 - unlikely to be used
uint8_t _id193_200; // 8 bit storage for 197 - 200 - unlikely to be used

void Monitor16(const int offset, uint16_t mask) {
for (int i = 0; i < 16; i++)
{
if (mask & 1)
{
if (GetInputState(EXTENDED_GRIPPER_OFFSET + i + offset + 1) == false)
{
Error(USER_ERROR_232, i + offset + 1, 1, false);
}
}
mask >>= 1; // shift the mask for next eval
}
}
void Monitor32(const int offset, uint32_t mask) {
for (int i = 0; i < 32; i++)
{
if (mask & 1)
{

if (GetInputState(EXTENDED_GRIPPER_OFFSET + i + offset + 1) == false)
{
Error(USER_ERROR_232, i + offset + 1, 1, false);
}
}
mask >>= 1; // shift the mask for next eval
}
}
void Monitor08(const int offset, uint32_t mask) {
for (int i = 0; i < 8; i++)
{
if (mask & 1)
{
if (GetInputState(EXTENDED_GRIPPER_OFFSET + i + offset + 1) == false)
{
Error(USER_ERROR_232, i + offset + 1, 1, false);
}
}
mask >>= 1; // shift the mask for next eval
}
}

public:
Monitor ()
{
AnyMonitored = false;
_id1_16 = 0; _id17_32 = 0; _id33_48 = 0; _id49_64 = 0;
_id65_96 = 0; _id97_128 = 0; _id129_160 = 0; _id161_192 = 0;
_id193_200 = 0;
}
~Monitor () {}

bool AnyMonitored;

void ClearMonitoring() {
_id1_16 = 0; _id17_32 = 0; _id33_48 = 0; _id49_64 = 0;
_id65_96 = 0; _id97_128 = 0; _id129_160 = 0; _id161_192 = 0;
_id193_200 = 0;
AnyMonitored = false;
}

void StartMonitoring(uint8_t id) { // set a single bit
id = id - 1; // 0-index
if (id < 16) {
_id1_16 |= (1 << id);
}
else if (id < 32) {
_id17_32 |= (1 << (id - 16));
}
else if (id < 48) {
_id33_48 |= (1 << (id - 32));
}
else if (id < 64) {
_id49_64 |= (1 << (id - 48));
}
else if (id < 96) {
_id65_96 |= (1 << (id - 64));
}
else if (id < 128) {
_id97_128 |= (1 << (id - 96));
}
else if (id < 160) {
_id129_160 |= (1 << (id - 128));
}
else if (id < 192) {
_id161_192 |= (1 << (id - 160));
}
else if (id < 200) {
_id193_200 |= (1 << (id - 192));
}
AnyMonitored = true;
}

void StopMonitoring(uint8_t id) { // unset a single bit
id = id - 1; // 0-index
if (id < 16) {
_id1_16 &= ~(1 << id);
}
else if (id < 32) {
_id17_32 &= ~(1 << (id - 16));
}
else if (id < 48) {
_id33_48 &= ~(1 << (id -

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

C++ - Reddit

I made gui windows portable app maker
https://github.com/xodudrkd/Portablium

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

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

C++ - Reddit

Learning modern or niche C++ topics without having any immediate need for them

I have been working professionally with C++ for the past 4 years, and I used it almost exclusively throughout my university years so another 4 years. I think I know the language fairly well on the fundamental level and I know some niche information about how some compilers / linkers work. I am in no way an expert, but I think it's fair to say I am not a beginner either.

My problem is, I work in the EDA industry, and in one of the "big" companies. The "big" EDA companies started out in the 80s / early 90s, so code has been slow to adapt. My particular situation is that we just moved to C++17 a couple of months ago.

This is a problem for me because, if I have no immediate need for something, I find it just so difficult to read through books and retain the knowledge I read through. It doesn't have to be immediate in the sense that it's something I am actively working on, but at least something I anticipate needing in the near future.

I also tried reading a book about C++ template metaprogramming but I seriously couldn't think of anything I could do with it so it was so hard to even exercise what I was reading beyond convoluted made up ideas with no practical value just so I have something to write. I dropped that book fairly quickly as a result.

I feel like I lack something generally, and I feel like what I lack is somewhere in that area I keep finding myself unable to explore.

I also thought it may be because I am not a library / framework developer, and those sorts of "advanced" techniques are usually geared towards those kinds of developers.

What do you guys think?

Also, book / talk recommendations are welcome if that's what you feel like providing.

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

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

C++ - Reddit

Finding my own C++

I use to write some C++ back then in 2000, but have not written or read C++ in that long. Now, I want to connect again with C++, because use to love the language. You can say I was fall in Love with it.

I am learning it all again, and is complicated. I don't want to submerge myself directly in a world where <template> and <std:string> is everywhere. I want to write some nice code that can interact easily with C, and that is clear to read, easy to understand and solid.

It somewhat feels like I am inventing my own version of C++, hopefully one that follow that line of through: easy to read and solid.

I did not liked much that when my code crash, theres not error message or anything. I mean, of course, but is sad that can't be prevented in some way. Like having access to erroneous areas of memory generate a exception or something.

I really like the idea that you can pass the pointer to a thing has reference or pointer. Maybe this is not a new thing, but feels new to me.

Anyone can point me to some online documentation with people writting articles about clean C++ code?, or code designed for maximum compatibility with C?

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

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