Category "c++"

How to get std array size in a constant expression?

Consider this code: #include <array> #include <cstddef> struct A { std::array<std::size_t, 4> test; void method() { std::size

is it safe to use boost::asio::streambuf as both an istream and an array as string_view?

For example, could there be problems with the memory work inside this buffer if I use code like this? Can I use the input stream and use sv (string_view) with t

Convert float pointer returned by c++ DLL function to float C#

extern The return is a pointer to the internal array containing results info. It should not be modified results values are output as a float array (mantissa

building a nested JSON

Some data files that I need to read / parse have headers in the style: level0var = value0 level0var.level1field = value1 level0var.level1array[11].level2field

Using Qt+ICC on Windows

I have a question about the use of the Intel C++ compiler on Windows for compiling Qt projects. I know that officially ICC is supported only by Qt on UNIX, but

Template partial ordering - why does partial deduction succeed here

Consider the following simple (to the extent that template questions ever are) example: #include <iostream> template <typename T> struct identity;

What will be the time complexity of this brute force apporach of finding largest valid bst in a binary tree?

int size(Node* root){ if (root == nullptr) { return 0; } return size(root->left) + 1 + size(root->right); } bool isBST(Node* node

How to know the name of a library installed with vcpkg?

In my simple app which I build with cmake I use opencv, which is installed with vcpkg. On CMakeLists.txt I have to find_package(OpenCV REQUIRED), replacing Open

Using 3rd party lib file in NodeJs and getting LNK2001 error

I have been searching for an answer for a while and couldn't find anything that worked. Here is some background: I am trying to build an electron app that can u

How to create custom tensor value with shape (b,n,m)?

How to create custom tensor value with shape (b,n,m) I see the cppflow::fill method but it allows inserting 1 value which fills the whole same value in the shap

How to load printf from UCRT DLLs?

I am trying to dynamically load printf from ucrtbase.dll, but GetProcAddress is returning NULL. Other functions like malloc and puts work, but not printf. int m

weird visual studio to linux results

I have this project where we have to convert a made up simple coding language given through a txt into a c++ language and currently I am having a problem with c

How to get characters from a file and display on console?

I got this code from notes about file handling. From what I understand about this code, I want to get characters till x is reached in the file using this code.

Issue with the return type of the `get_mpz_t` function of GNU MP

The GNU MP manual specifies the declaration of the function get_mpz_t: Function: mpz_t mpz_class::get_mpz_t () So I was expecting a mpz_t return type. But runn

How to properly use glTexImage2D to render an object each frame?

This is the code for a ground object that gets rendered every frame in a game I'm making with c++ and openGl. Ground::Ground() { this->loadedObject = loa

select a screen section ffmpeg c++ on macos

I am trying to record the screen on macos, with ffmpeg. I would like to be able to select a section of the screen instead of the whole desktop. I tried to set s

How to interpret the explicit cast operator

As we can invoke the explicit cast operator, using static_cast, a C-style cast, or a constructor style cast. I am confusing how exactly the operator interpret t

MCUxpresso imr rt - Position Independent Code result in mem fault on free rtos task activation

I have a dev board (imx rt 1024) from nxp, which I write software for using MCUxpresso (nxp's IDE). For my project, I am asked to introduce position independent

Why is C++ getline() non-blocking when program is called from python subprocess?

I have a C++ program that waits for some text input with getline(), and it works well from the command line. However, I would like to call it from Python - send

Datetime parse and format in C++

I'm using time_point the first time. I want to parse datetime from string and found a difference when returning back to string from 1 hour. std::chrono::system_