Hi! ✌️ I need to generate some string in C++ with random characters that can use all letters from "a" to "z" (include capital letters), and all numbers from 0 to 9 there.
And for examples this should looks somehow like this:
SnHXAsOC5XDYLgiKM5ly
Also I want to encrypt that string then by itself:
SnHXAsOC5XDYLgiKM5ly encrypt with SnHXAsOC5XDYLgiKM5ly key.
Last week, C++26 was finalized in Sofia, Bulgaria — and C++26 will include all of the reflection papers that we were pushing for:
Link Actions
So today I wanted to talk about a very cool example that Dan put together on the flight home from Sofia, while I was unconscious a few seats over: the ability to, at compile time, ingest a JSON file and turn it into a C++ object.
for anyone who doesn't know, this "-Werror=switch-enum" compiler option make the compiler throw an error if all of the enum values aren't explicitly handled in a "switch" statement
cpp
enum class colors {
blue,
red,
purple,
}
void func(colors c)
{
switch(c)
{
case colors::blue:
// do something
break;
case colors::red:
// do something
break;
default:
// do something
break;
}
}
int main()
{
func(colors::blue);
}
this code doesn't compile on clang and gcc with the option "-Werror=switch-enum" because the "colors::purple" isn't explicitly handled. be aware that it doesn't throw a compiler error for "if" statements if one of the values isn't handled
an easy to use header only JSON library for C++20. Contribute to nodeluna/ljson development by creating an account on GitHub.
Link Actions
It's not fully finished yet, but it's getting there, and i didn't write documentation beyond the README.md and tests/test.cpp but I'd like some feedback on it.
features
It's a header only library that's currently < 3000 loc
no 3rd-party dependencies
support for being imported as a module
supports inserting std containers into json nodes
highly type safe, which is made possible by using concepts
easy-to-use object/array iterations
easy-to-use type casting from json value to native c++ types which is enabled by std::variant and concepts
exception-free parsing and value casting.
modern error handling using "expected" type
! exception-free node.try_at("key") access is still not implemented but planned
A unique milestone: “Whole new language” Today marks a turning point in C++: A few minutes ago, the C++ committee voted the first seven (7) papers for compile-time reflection into draft…
Herb Sutter just announced that the verdict is in: C++26, the next version of C++, will include compile-time reflection.
Reflection in programming languages means that you have access the code’s own structure. For example, you can take a class, and enumerate its methods. For example, you could receive a class, check whether it contains a method that returns a string, call this method and get the string. Most programming languages have some form of reflection. For example, the good old Java does have complete reflection support.
Frequently, whenever the topic of Reflection comes up, I see a lot of complains specifically about the new syntax being added to support Reflection in C++26. I’ve always thought of that as being largely driven by unfamiliarity — this syntax is new, unfamiliar, and thus bad. I thought I’d take a diff...
Link Actions
Let’s take a problem that can only be solved with Reflection and compare what the solution would look like between:
the C++26 value-based model
the Reflection Technical Specification (TS)’s type-based model
Intro # Vcc - the Vulkan Clang Compiler, is a proof-of-concept C and C++ compiler for Vulkan leveraging Clang as a front-end, and Shady our own research IR and compiler. Unlike other shading languages, Vcc aims to stick closely to standard C/C++ languages and merely adds a few new intrinsics to cove...
Link Actions
Vcc - the Vulkan Clang Compiler, is a proof-of-concept C and C++ compiler for Vulkan leveraging Clang as a front-end, and Shady our own research IR and compiler. Unlike other shading languages, Vcc aims to stick closely to standard C/C++ languages and merely adds a few new intrinsics to cover GPU features. Vcc is similar to CUDA or Metal in this regard, and aims to bring the advantages of standard host languages to Vulkan shaders.
Key Features
Vcc supports advanced C/C++ features usually left out of shading languages such as HLSL or GLSL, in particular raising the bar when it comes to pointer support and control-flow:
Unrestricted pointers
Arithmetic is legal, they can be bitcasted to and from integers
Generic pointers
Generic pointers do not have an address space in their type, rather they carry the address space as a tag in the upper bits.
True function calls
Including recursion, a stack is implemented to handle this in the general case
This article covers the development of a Sega Genesis 16-bit console emulator in C++. A lot of exciting stuff awaits you ahead: emulating the Motorola 68000 CPU, reverse engineering games, OpenGL...
I’ve written plenty on this blog about standard algorithms, but far less about ranges. That’s mostly because, although I’ve had production-ready compilers with C++20 ranges since late 2021, the original ranges library lacked a few key capabilities. The biggest gap was at the end of a pipeline: you c...
For several months, our team has been actively testing the new parser version, and we′ve made significant progress. Thanks to users′ feedback, we′ve identified and fixed many analyzer issues...
Sooner or later, any developer working with C-like languages gets the idea of treating a two-dimensional array as a one-dimensional one. The reasons vary, but the result is usually the same. In this...
In recent weeks, we’ve explored language features and library features becoming constexpr in C++26. Those articles weren’t exhaustive — I deliberately left out one major topic: exceptions. Starting with C++26, it will become possible to throw exceptions during constant evaluation. This capability is...