C++ - Reddit
227 subscribers
48 photos
8 videos
1 file
25.3K links
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
Download Telegram
The way to do error handling

[the link](https://github.com/Quaentor/status)

If you could be oh so kind, please tell me what you think.

This thing is a pretty general thing, and also highly composable. Because it is not only a set of classes, but a radical idea on how should be written code that deals with error handling, it is just impossible to describe it fully in a sane amount of words.

Considering the extra classes the repo contains, it already gives you several ways to handle the problem. It was designed to be extended for the needed functionality to handle the problem just how You want to. But with the extra classes you probably would already have all you need.

​

The repo contains:

* the main class `basic_status`, with which you can determine what type of error it was initialized with. It only stores the type. The class contains only one member of integral type. And all operations with it in assembly should take only one instruction.

​

struct Error1{}; struct Error2{};

To write a function that returns a status you would write

status<Error1,Error2>
foo(){
if(...) return Error1{};
else return Error2{};
return {};
}

To determine if it failed you would write

if(auto s = foo(); !s)

To check if it returned a particular status you would write

foo().is<Error1>()

If `Error2` was to be defined as `struct Error2 : Error1{};`, `foo().is<Error1>()` would return `true,` if `foo` returned `Error1` or `Error2`.

&#x200B;

* the extra classes which all derive from `basic_status` :

`basic_holding_status` for storing the object of the current type. The object would be of type `Error1` or `Error2`, so you could initialize them in `foo` with some data.

`basic_acting_status` for giving a way to write a function that would be called when the status was initialized with some type(unsuccess state). You can choose when exactly the function is called -- in constructor of the status, in destructor, in destructor if the result was not checked.

I lied that they derive from `basic_status`. They derive from a template parameter, meaning you can combine them (an example can be seen in the [first link](https://wandbox.org/permlink/POagc0Sact7acFEo) in the repo, in file test\_acting)

&#x200B;

The repo contains a couple of links, where you can see some examples.

The main reason why there aren't too many (though I think it's enough) is it's not mature enough yet to give examples on how to do things.

It could become mature enough with your suggestions and requests.

Maybe it's not that of a good idea, and it's not worth it. So tell me what you think.

https://redd.it/ejk5ui
@r_cpp
What is the best way to Develop And Debug sources in linux which is guest in virtualbox which in windows?

Hello all

im looking to visual debug c++ source which are running in linux (centos) that i installed on guest in virtualbox which in windows.

in shourt i like to develop on windows ( using VS or Eclipse or netbeans ) application that is running on linux

thanks

https://redd.it/ejm9i5
@r_cpp
The most useless piece of code I have ever written

\#include <iostream>

double b(double d)

{

return d / d;

}

int main()

{

double num;

std::cout << "Choose a number to divide by itself." << std::endl;

std::cin >> num;

std::cout << b(num);

}

https://redd.it/ejwmwr
@r_cpp
Looking for Partners for a new Gaming RP Community

**Company:** Confidential (RedM Role Play Community)

**Type:** Flexible - contract, internship, other

**Description:** Have you heard of FiveM for GTA? If so, then you may have also heard of RedM for Red Dead Redemption 2?

I am looking to start a community for role players interested in playing on the modded version of Red Dead in a private server for the purposes of entertainment and content creation.

I have experience running communities, I have a great name reserved, and I have the ability to fund the project. Unfortunately, I need developers to help build the server and its scripts. You will be paid for your contributions.

**Location:** Completely Remote

**Remote:** Yes

**Visa Sponsorship:** N/A

**Technologies:** Most scripts are written in either C++ or Lua. Past experience preferred. Experience with FiveM a plus.

**Contact:** If interested, please DM me here. If you have general questions that benefit others, you may reply to the post if rules allow.

https://redd.it/ekfrrp
@r_cpp
Flecs 1.2: Introducing a C++11 API

Link to the release: [https://github.com/SanderMertens/flecs/releases/tag/v1.2](https://github.com/SanderMertens/flecs/releases/tag/v1.2)

Flecs is an Entity Component System written for C89, C99 and now C++11! Its unique features are a super fast SoA-based storage, a fully-fledged (nested) prefab workflow, hierarchies, time management and a plug&play module system.

If you'd like to know more about ECS, see [https://github.com/SanderMertens/ecs-faq](https://github.com/SanderMertens/ecs-faq).

Flecs 1.2 features a new header-only C++11 API that follows modern C++ best practices. For example code see: [https://github.com/SanderMertens/flecs/tree/master/examples/cpp](https://github.com/SanderMertens/flecs/tree/master/examples/cpp)

Other new features in 1.2 are:

* Snapshots, a fast & lightweight mechanism for restoring a game to a previous point in time
* A new blob serializer for streaming games to/from a disk or network
* On demand systems that are only executed when there is interest in their output
* A new statistics API for monitoring server-side Flecs applications
* 24 new API functions
* And much more, see the [release notes](https://github.com/SanderMertens/flecs/releases/tag/v1.2) for more information.

https://redd.it/ekv776
@r_cpp