Category : c++17

I’m using XMacro COMPS to define enums and some other metadata like name, index, flag=(1<<index), etc at compilation time. Here’s an example how I’m using it to generate the index: template <unsigned ROUTINE> constexpr int C_Index() { switch (ROUTINE) { #define MX(a,b) case a: return b; break; COMPS #undef MX default: return 0; } } ..

Read more

I have a task to save "calls" to some free functions along with their params. This "calls" are filtered and applied later with std::apply(func, tuple); For now I have come to the following abstraction: class … { public: using E2Func = std::function<void(uint32_t, uint32_t)>; void SomeFunc(uint32_t x, uint32_t y) { CommonNamedState(__func__, SomeFuncImpl, x, y); } //more ..

Read more

I’m trying to serialize/deserialize data to/from std::vector<std::byte>. The code below shows one solution with boost::serialization, but I think this applies to other serialization libraries. The problem with the solution is that it uses use std::ostringstream and std::string. I would like to avoid those and avoid the std::memcpy asociated with them. Is there an elegant way ..

Read more

The following snippet of C++17 code compiles in GCC and CLang, but in Visual C++ it gives the error C2784: Could not deduce template argument. https://godbolt.org/z/o4fe351Kn #include <iostream> #include <vector> template< template <typename…> typename container > std::ostream & f (std::ostream & out, const container< int > &) { return out; } std::ostream & operator << ..

Read more

Clang error : invalid operands to binary expression (‘const auto’ and ‘int’) Context : Clang 12.0.0 Simple questions : What does this error means in this context ? (e.g is the message relevant here ?) Why does this error only occur when compiling with Clang, in opposition to GCC and Msvc-cl ? Here is a ..

Read more