Category "c++"

accessing std::tuple element by constexpr in type

I would like to access to a tuple element at compile time by a value constexpr in the type #include <iostream> #include <tuple> #include <utility

Iterate through a C++ Vector using a 'for' loop

I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the fi

Benefits of header-only libraries

What are the benefits of a header only library and why would you write it that way oppose to putting the implementation into separate file?

Why does const have to be added to constexpr for a string literal declaration?

This declaration: char constexpr *const s = "hello"; Fails with this error: g++ -g -Wall -Werror -std=c++17 test.cc -o test test.cc:8:31: error: ISO C++11 d

What is the C++ equivalent of Python's "in" operator?

What is the C++ way of checking if an element is contained in an array/list, similar to what the in operator does in Python? if x in arr: print "found" els

Can we have recursive macros?

I want to know if we can have recursive macros in C/C++? If yes, please provide a sample example. Second thing: why am I not able to execute the below code? Wh

Using GLAD for Raspberry Pi project

I am trying to figure out how to create a window for my project. I want to work with OpenGL ES and I found online guides on how to use X11 and EGL for creating

Why can't a weak_ptr be constructed from a unique_ptr?

If I understand correctly, a weak_ptr doesn't increment the reference count of the managed object, therefore it doesn't represent ownership. It simply lets you

How to use enums in C++

Suppose we have an enum like the following: enum Days {Saturday, Sunday, Tuesday, Wednesday, Thursday, Friday}; I want to create an instance of this enum and

In Vulkan, is it beneficial for the graphics queue family to be separate from the present queue family?

As far as I can tell it is possible for a queue family to support presenting to the screen but not support graphics. Say I have a queue family that supports bot

Serialization without Boost.Serialization

I'm trying to implement a simple serialization/deserialization method for my code to be able to pass an object over the network using MPI. In an ideal world I w

What does "Cannot overload functions distinguished by return type alone" mean?

I have this code: In the header: ... int32_t round(float v); ... and in the source ... int32_t round(float v) { int32_t t = (int32_t)std::floor(v);

How to override other windows application's elements? [closed]

Can you please point me into the right direction? I want to edit other application textbox or click, programmatically. For example, in a web

C++ to simpler language (Python, Lua, etc) converter? [closed]

I know Python and I've come across a small C++ source file I would like to convert to Python. But the C++ code is too complex for me to unders

How to decode mpeg motion vector using OpenCV in C++?

I want to decode the MPEG motion vectors using OpenCV in C++. Is there any function in OpenCV through which we can get this? Brightness may not be constant thro

How to turn on (literally) ALL of GCC's warnings?

I would like to enable -- literally -- ALL of the warnings that GCC has. (You'd think it would be easy...) You'd think -Wall might do the trick, but nope! Stil

How do I access the `addr2line` functionality within my C++ program?

I need to get the information provided by addr2line (source file and line from backtracing a function call) from within a C++ program. I know I can call addr2li

C++ Arrays and writing of values

I'm trying to write a punnett square generator for a biology class, it's quite simple, but I can't figure out how to get the values to write to the other blocks

Getting Started with crypto++ decryption with AES

I'm trying to learn a bit about cryptography and am trying to use AES decryption with the crypto++ library in c++. I have a ciphertext string and a key string.

Why is processing a sorted array faster than processing an unsorted array?

Here is a piece of C++ code that shows some very peculiar behavior. For some strange reason, sorting the data (before the timed region) miraculously makes the l