Announcing CAF Version 1.0
https://www.actor-framework.org/blog/2024-06/announcing-version-1.0
https://redd.it/1doyiu0
@r_cpp
meta Can we do something about the constant HFT questions?
Last several weeks, my view of this subreddit (maybe its just me? I can't tell...) Is that its just questions about high frequency trading.
C++ is so, so much more than high frequency trading.
Is it reasonable to ask for some official rules or guidelines that discourage these kinds of posts?
I know we already have the /r/cscareers (or whatever spelling) subreddit. If that's the designated place for these questions, can users report posts about HFT careers questions to get them removed and redirected to the cscareers subreddit by mods?
https://redd.it/1dorx42
@r_cpp
I Typed All The Subtitles For the "C++ in 100 Seconds" Video
https://youtu.be/MNeX4EGtR5Y?si=T9qAvHJkxogY1Omr
I think I learn better when I'm reading out loud, instead of just reading or listening to something. Im trying to learn C++ so i typed all the subtitles of the video above so I can speak it outloud, and i just wanted to share it.
There was already auto-generated subtitles on the video, but I prefer to read at my own pace, and not quickly read the subtitles.
Also, the video is almost 3 minutes long, im not 100% sure why its titled "in 100 seconds", but i still enjoyed the video regardless.
--------------------------------------------------------------------------------------
C++ a statically typed compiled programming language famous for its widespread use and software infrastructure and infamous for its steep learning curve it was created in 1979 by Bjarne Stroustrup at attnt bell labs he was inspired by the object-oriented nature of simula but needed a language with a high performance of c and thus c with classes was born its designed as a super set of c which means that virtually any c program is also a valid c++ program but it also adds zero overhead abstractions such as object orientated patterns like polymorphism, encapsulation and inheritance today its used in a wide variety of systems with constrained memory demands like the unreal engine for AAA video games programs like adobe after effects that were used to edit this video databases like mysql and mongodb embedded systems like the display on your smart toaster and is used to implement much or our low-level infrastructure like language compilers and virtual machines its so popular because it provides low-level memory and hardware control like c but with high level abstractions like classes and smart pointers c++ makes it harder to shoot yourself in the foot but when you do it'll blow your whole leg off
To get started install a c++ compiler like gcc or clang then create a file ending in cpp include io stream from the standard library to handle input and output your code will start executing from the main function to print hello world we simply use standard character output followed by the bitwise shift left operator and a string literal we can get rid of this std though by adding a name-space to the top of the file now if we want to create a string variable we can do so by typing it as an array of characters however if we include string from the standard library we can use the string type instead the real game changer though is the fact c++ supports object-oriented programming with classes a class is just a blueprint for an object inside a class you can define attributes and methods that will be private by default or make them public by adding them under the public specifier its also possible to define methods outside the class definition using a double colon methods can also be defined multiple times with different parameters which is known as overloading and is a form of polymorphism in addition we can define constructors and destructors to run code when an object is created or destroyed classes also support inheritance allowing developers to more efficiently share logic throughout a program to instantiate an object type the class name followed by the name of your object and optionally any parameters for the constructor when it comes to memory we could manage everything manually with pointers and references however tools like unique pointer can get the job done in a way that's easier and safer by ensuring that only one object can be allocated to memory now to run your code open up the terminal and use a tool like clang plus plus to compile it.
This has been c++ in 100 seconds hit the like button and subscribe if you want to see more short videos like this thanks for watching and I will see you in the next one
https://redd.it/1doftmd
@r_cpp
only is there a boost::program_options library in C++ (that does the right thing and returns an object collection to represent the parsed command line), it has defaulting from a configuration file built-in as a feature! Now, this is the first C++ program I have written, other than “hello, world”, and C++ is a hoary old cruft-fest, so it doesn’t go fast.
But it still takes half the time, half the effort, and under half the lines of code that it does in Go. And remember, I just started coding in C++ this week, while I have been tinkering with Go off and on for the past year.
https://redd.it/1do9b05
@r_cpp
at most, we'll have an exception base class to be able to catch all exceptions and provide some information as oppose to the catch all statement providing no info aside knowing something went wrong.
The last thing missing is adding the category, but that's just adding another template type and doing the whole mirroring the type hierarchy shenanigans to be able to do permutations.
For now this has been a thought experiment, I'll be trying to use it in my own code bases but I wonder, how do you extend your exception hierarchy?
https://redd.it/1dhk726
@r_cpp
Need thoughts on my collision system
I'm making a game in C++ using Raylib. Currently i have a HitboxComponent class. Anything that is collidable will have an hitbox object. Currently i have a CollisionSystem class that holds a map of a CollidableType (for example, BOX, ENEMY, etc...) and a pointer to the HitboxComponent. I iterate over the map checking for collisions. I thought this would work, but now I have a problem. What if I wanna make a bullet for example? Since i only have the hitbox I can't access the actual object.
I thought of making an entity or collidable class and add a onCollide virtual function and pass them instead of the HitboxComponents. Is that a good idea?
https://redd.it/1dhilrd
@r_cpp
When is a good time to use pointers?
Hello, I am currently writing a game engine to study cpp and software concepts. One thing I’ve noticed in my code is I tend to have one instance of an object (like a command buffer for Vulkan) then the command buffer gets passed into the functions that require it by a commandBuffer*. But, this tends to be a very common habit I’ve picked up, and usually I use std::unique_ptr or std::shared_ptr instead of raw pointers. I just want to make sure that I’m using pointers correctly and not making any big mistakes.
Also, when is it an appropriate time to use unique and shared ptrs?
Thanks.
https://redd.it/1dh0crg
@r_cpp
Framework para lua
A DLL made in C for Lua aimed at creating APIs and desktop web applications (such as VSCode, Postman, etc.). It was designed to be as intuitive as possible, with various features and configurations. It is open-source.
The name of the framework is serjaoBerranteiroServer: https://github.com/SamuelHenriqueDeMoraisVitrio/SerjaoBerranteiroServer
Currently, it only supports Linux, but it can be tested on WSL.
https://redd.it/1dgx884
@r_cpp
ClangQL 0.5.0 support unions info, arrays, slices
https://github.com/AmrDeveloper/ClangQL
https://redd.it/1dgpgkz
@r_cpp
Save $800 at CPPNorth with Exclusive Hotel & Ticket Combo Offer!
Hey everyone,
We're excited to share an exclusive offer for those planning to attend CPPNorth this year! If you book a four-night stay at the Royal York Hotel, you can save $800 on a combo that includes both your conference ticket and a ticket to the Belonging Dinner. This special deal is perfect for those looking to make the most out of the conference experience in comfort and style.
**Offer Details:**
* **Stay**: [Book a minimum of four nights at the Royal York Hotel.](https://book.passkey.com/go/0724CPPN001)
* **Save**: [Purchase your conference and dinner tickets together to get an $800 discount.](https://store.cppnorth.ca/cart/42872706728094:1,43171641557150:1?discount=ROYAL_YORK_HOTEL)
* **Act Fast**: This offer is only valid until June 21, 2024.
Whether you're a regular at CPPNorth or this is your first time, this deal is a great way to enhance your experience at one of the leading tech conferences in Canada. Enjoy the convenience, networking opportunities, and, of course, the savings!
For more details and to claim your discount, check out the link: [cppnorth.ca/news-2024-hotel-discount.html](https://cppnorth.ca/news-2024-hotel-discount.html)
Looking forward to seeing many of you there! If you have any questions or want to discuss more about the conference or the offer, feel free to comment below!
https://redd.it/1dg2e8i
@r_cpp
std::array use of ->
I'm struggling to understand the way that -> is used in the std::array constructor. What is -> doing?
https://github.com/llvm/llvm-project/blob/main/libcxx/include/array#L384
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/array#L294
template <class _Tp, class... _Args, class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> >
array(_Tp, _Args...) -> array<_Tp, 1 + sizeof...(_Args)>;
https://redd.it/1dfy8ig
@r_cpp
I wrote a C++ book!
https://blog.knatten.org/2024/06/12/i-wrote-a-c-book/
https://redd.it/1dfw3xv
@r_cpp
CppCast: Boost, The Beman Project and Beyond
https://cppcast.com/boost-the_beman_project_and_beyond/
https://redd.it/1dfmnde
@r_cpp
Best way to create a GUI in cpp
I created a mini linear algebra library in cpp that does inversion and other basic operations/computations. I want to create a GUI for this, and I’m not very sure how to go about it. Any advice on how ti approach this would be greatly appreciated!
https://redd.it/1dfh5qa
@r_cpp
Improving Date Formatting Performance in Node.js
https://akr.am/blog/posts/improving-date-formatting-performance-in-node-js
https://redd.it/1dfa5zk
@r_cpp
std::tie and RAII
How would you go about respecting RAII with std::tie?
I want to return two values from a function. Therefore I use std::pair to pack them together.
In order to assign the return value to a variable, I use std::tie like this: int nValue1, nValue2; std::tie(nValue1, nValue2) = function();
However this is in conflict with RAII principle.
Is there a possibility to initialise both values with a single function call?
https://redd.it/1dox1wm
@r_cpp
Which path in HF/HFT to take
How is back office career compared to low latency career in hedge funds / HFT firms? Would you take a paycut to work on low latency C++?
https://redd.it/1don44m
@r_cpp
For loop control variable gets assigned with empty string in second iteration onwards
I have following C++ snippet:
std::string someVar;
configuration = YAML::LoadFile(configurationFilePath);
std::vector<std::string> necessaryKeys = {"abc","xyz","uvw","lmn"}
for(const auto key: necessaryKeys){
//..
if(key == "xyz") {
someVar = "someconfigkey";
}
//..
}
filePath = mRootDir + configurationsomeVar"ConfigurationFilePath".as<std::string>();
My code crashed with following error:
terminate called after throwing an instance of 'YAML::TypedBadConversion<std::cxx11::basicstring<char, std::chartraits<char>,
std::allocator<char> > >'
what(): bad conversion
So, I debugged the whole thing only to notice some weird behavior. for
loop control variable key
correctly gets assigned with the first value abc
in necessaryKeys
. However, in all further iterations, it gets assigned with empty string (""
). Thus the variable someVar
inside for
loop's body never gets assigned with the value some_config_key
. This results in configuration[someVar]["ConfigurationFilePath"].as<std::string>()
to fail, probably because there is no YAML node associated with configuration[someVar]
(that is, configuration[""]
) and hence configuration[someVar]["ConfigurationFilePath"]
is probably NULL
. This seem to force as<std::string>()
to throw bad conversion error.
The error gets thrown from this line in yaml-cpp library:
if (node.Type() != NodeType::Scalar)
throw TypedBadConversion<std::string>(node.Mark());
The node.Type()
is YAML::NodeType::Undefined
in debug session.
Why key
is getting assigned with empty string second iteration onwards? Or my C++ noob brain misunderstanding whats happening here?
https://redd.it/1dof75y
@r_cpp
Different library version dependency on the same project with CMake
I ran into a dead end attempting to figure out how to use installed libraries and manage library dependencies taking the version into consideration.
Consider the following:
- I've made a LibA project and turned it into a library installed in a custom folder in my workspace(.install folder)
- LibA has two versions: 1.0.0. and 2.0.0
- LibB is another library also installed in this custom folder in the workspace but it depends on the LibA 1.0.0
- Finally, an App depends on the LibA 2.0.0 and the LibB 0.1.0
The main issue is that the App is linking the LibA 2.0.0 while LibB also depends on the LibA, but the LibB is not using the LibA 1.0.0.
Has anyone ever encountered something similar? Any thoughts or recommendations on how to resolve this matter would be greatly appreciated.
I'm not sure whether or not the find_package is the better option here.
NOTE: I'll let below a small piece of the CMakeLists.txt file to help
App/CMakeLists.txt:
# LibA dependency set(LIB_A__VERSION 2.0.0)
list(APPEND CMAKE_PREFIX_PATH "$ENV{MY_WORKSPACE}/.install/LibA/${LIB_A__VERSION}") find_package(LibA ${LIB_A__VERSION} EXACT REQUIRED) target_link_libraries(${EXECUTABLE_NAME} PRIVATE LibA)
# LibB dependency
set(LIB_B__VERSION 0.1.0) list(APPEND CMAKE_PREFIX_PATH "$ENV{MY_WORKSPACE}/.install/LibB/${LIB_B__VERSION}")
find_package(LibB ${LIB_B__VERSION} EXACT REQUIRED) target_link_libraries(${EXECUTABLE_NAME} PRIVATE LibB)
LibB/CMakeLists.txt:
# LibA dependency set(LIB_A__VERSION 1.0.0)
list(APPEND CMAKE_PREFIX_PATH "$ENV{MY_WORKSPACE}/.install/LibA/${LIB_A__VERSION}") find_package(LibA ${LIB_A__VERSION} EXACT REQUIRED) target_link_libraries(${EXECUTABLE_NAME} PRIVATE LibA)
https://redd.it/1dhklsc
@r_cpp
Reimagining the exception hierarchy
One of the remaining things I've been trying to figure out was when should I make a new exception type, and when I do, which one should I inherit from?
My troubles are the following:
* If I want to add information to an existing exception type, say `std::out_of_range`, inheriting feels wrong due to if something catches the base type up stream when that's unintended, it may cause problems.
* If I decide to not inherit from `std::out_of_range` for my custom `out_of_range` error, now I have 2 types sharing the exact same semantics as each other and the opposite issue of the previous, what if it's intended the base class gets caught, so that also feels wrong to me.
* The base classes `std::logic_error` and such, I read them as categories of errors, but what if I don't agree for my use case that they aren't the correct category
Basically, the leaves of the current hierarchy are the "what went wrong", the base class is a "category", and if I wanted to add my own data to existing errors I view this as "where it went wrong".
To fix these issues I thought of turning to multi-inheritance and templates. What if I created a template type to indicate which module of the code base the error came from. For example
class FooBase
{
};
template<class Exception>
class Foo : public Exception, public FooBase
{
};
With this approach I could specialize to add new information, but it doesn't fix unintentionally catching the base class.
The fix here would be simple, just declare another template which would indicate the error could've came from anywhere and by default, throw and catch those. So with this approach we can now catch all errors coming from `Foo` by catching `FooBase`, catch any `std::out_of_range` errors, or catch specifically `out_of_range` coming from `Foo`, but we an issue. If I threw `Foo<std::out_of_range>`, what if I wanted to catch `Foo<std::logic_error>` instead? The above wouldn't work because it doesn't inherit from said type. It'd be fine if the exception was empty, but if it's not, we're duplicating the base types N times along with it's data. Virtual inheritance won't save us here because `std::out_of_range` doesn't virtually inherit `std::logic_error` so we can't collapse them.
To solve this, that's right, more templates. Our new solution will look like this
class Foo
{
};
template<class Module, class Exception>
struct CustomExceptionData;
template<class Module, class Exception>
class ShadowExceptionTree : public ShadowExceptionTree<Module, Exception::base>
{
virtual CustomExceptionData<Module, Exception> Data() = 0;
};
template<class Module, class Exception>
class ShadowExceptionLeaf : public ShadowExceptionTree<Module, Exception>, public Module, public Exception
{
CustomExceptionData<Module, Exception> data;
};
The idea here is to make a separate branch in the type hierarchy which mimics the exception type's hierarchy, but tagged with the module, and since it's tagged with it's module, we're able to catch the base classes with said information. Specialization to add data would be moved to this `CustomExceptionData` struct because the data would now live in the shadow leaf class. The leaf class isn't really meant to be caught, it's just there to set up the inheritance tree with minimal need for the user to do anything.
The user would only have to do 2 things at most.
* If they want custom data, they specialize the `CustomExceptionData` and make sure it mirrors the hierarchy as well.
* If they declare a new exception which also inherits type hierarchy, expose an alias that would give it's base type so that the `ShadowExceptionTree` knows how build the hierarchy.
The 2nd point could probably be simplified when we get static reflection, so just specializing the data type is all that's needed. That said, if we just had a exceptions without a hierarchy, we could skip this step all together and use the original simplified model. Though I'm sure
StockholmCpp 0x2F: Intro, infos and a Coding Quiz
https://youtu.be/fMHq4cKFhUs
https://redd.it/1dhdmtm
@r_cpp
What can i start creting with C++ to earn money?
Hello guys, I'm not that advanced in C++, and I'm pretty sure the thing that will make me go more in this language and get motivated to go deeply in it, is by building projects, so how to start making some simple projects and get money with, i know it's kinda stupid question but i hope you guys got what i mean.
https://redd.it/1dgx7px
@r_cpp
cpp gui for mac
I was wondering if anyone had any suggestions for a some-what simple gui for c++?
https://redd.it/1dgqdri
@r_cpp
Template Language Generator
I made a template generator for C/Cpp language that can make your life easier.
Here are the details.
Template\_Language\_Generator
A small POSIX shell script for generating a C/C++ code structure, build system files, etc.
# Current Features
C or C++
Library or Executable
Static or Dynamic (Linking)
Automagically generates README, LICENSE and MakefilesA small POSIX shell script for generating a C/C++ code structure, build system files, etc. Current FeaturesC or C++ Library or Executable Static or Dynamic (Linking) Automagically generates README, LICENSE and Makefiles
For Usage just run: `./cgen.sh`
https://redd.it/1dghp6v
@r_cpp
Tutor directx11
Hi I am looking for a tutor in directx 11. If you a tutor please dm me. Then we can talk privately
https://redd.it/1dfz5d2
@r_cpp
staticassert(std::isenumv<std::byte>);
The statement static\assert(std::is_enum_v<std::byte>); is true on gcc14 and clang18, not sure with msvc.
So according to cppreference `std::is_enum`: "Checks whether T
is an enumeration type."
My question is, is std::byte then an enum?
https://redd.it/1dfwtqf
@r_cpp
Why doesn't C++ add protected
keyword?
Why is there even a private
section in a class of C++? The main point is the user of the class shouldn't access those variables/functions. But C++ could have added protected
keyword so that the values of a class can only be read and not be written so there wouldn't be a need for getter & setter functions. That is turly bloat.
https://redd.it/1dfo3be
@r_cpp
Destructuring Lambda Expression Parameters
https://vector-of-bool.github.io/2024/06/13/lambda-destructure.html
https://redd.it/1dflmdj
@r_cpp
Testing Non-Blocking Circular Buffer?
I have some code that was created from scratch mostly. It’s a generic class.
Can anyone think of a way to test the living hell out of it (multiple threads of course 😀)?
I could probably write a test harness for it but if someone knows a prebuilt and reviewed test harness that’d be awesome!
It’s implemented in an .hpp as a template class
https://redd.it/1dfcs0s
@r_cpp
Performance comparison: linear search vs binary search (throughput + latency)
https://dirtyhandscoding.github.io/posts/performance-comparison-linear-search-vs-binary-search.html
https://redd.it/1df9mxw
@r_cpp