Category "c++"

Function template in header: implicit instantiation duplicated or shared?

Following function template is defined in Foo.h. #include <array> using namespace std; template<unsigned N> array<int, N> gen_arr() { array

Merging two sorted array on third by creating a new array on heap

I have a class array inside which I have declared an array its size and length. I am trying to merge two sorted arrays by creating the third array on the heap a

Is there a way to get win32 file handle from pipe's C file descriptor (python)?

Searched for about 1 hour and still unable to find any relevant search results. I want to wait on multiple pipes in a single thread, but unable to convert the f

How to make an overload for templated functions for a custom container's iterator

This is a generic question about templating, I am using advance as an example. Assume there are reasons I can't use ADL or hidden friends here. The definition o

How can I change map 's second component?

#include <iostream> #include <map> using namespace std; int main() { map<int, int> ma; // 원소를 추,

value of set::find() if not found in container

I am trying to understand std::find(). Below is my code. std::set::find searches the container for an element equivalent to val and returns an iterator to it i

Too many copies of the function to use std::move in C++

I have 2 classes: A and B. I need to pass instances of them to a function that will push them into a vector. I want to have good efficiency in my program, so I

why dont we need to refer to class name when referring to methods in c++

Coming from a good foundation in java to c++, I'm really confused on why when we use the cmath library we don't have to call it like: classname.function like we

What is an undefined reference/unresolved external symbol error and how do I fix it?

What are undefined reference/unresolved external symbol errors? What are common causes and how to fix/prevent them?

SSE1,2,3 round() not fully follow std::round() result

I'm trying to make similar to std::round() function using SSE(1,2,3) instructions but have some issues with certain values and/or logical operators. Here's my c

Is it legal to have 2 header files for the same class in c++?

In a project I read, there are two header files and two declarations for the same class. One is used by programs that use this library, serving as an interface.

Cannot build multiple CPP files with VSCode

I've followed the instructions here to setup VSCode with C++ on Windows 10 with MingGW https://code.visualstudio.com/docs/languages/cpp and I've followed the in

Calling a purely template lambda callback in C++20 [duplicate]

With C++20, we've gained templated lambdas, great! []<class T>(){}; Is it possible to call a lambda callback with a template parameter,

On the conversion from std::string type to template T type in C++

I've found on this forum the following snippet witten by user Ben Voigt: //forward declaration template<typename T> T getline_as(std::istream& s); te

Trouble figuring out a segmentation fault on a function call

Still new to c++ so I apologize if this is really obvious or something. Currently I have a small program (~250 lines) throwing a segmentation fault. There's a s

Raycasting rendering - wall's edge crossing issue

I'm implementing a fake 3D rendering using raycasting method (such as Wolfenstein3D). I have following the permandi's tutorial (https://permadi.com/1996/05/ray-

Why is this happening with my C++ application? [closed]

I'm currently learning C++, and at the moment I'm starting off by making multiple kinds of calculators to test my problem solving capabilities

sprintf precision typecasting leading to compilation warning

I have the below C++ code which issues a compilation warning as shown below. Case 1: char temp_buffer[80]; double **data; .... sprintf(temp_buffer, "%.*g", size

Changing function in an object's member

I am trying to write a very simple game using C++ and SDL2. I have a gameObject class and a player object. I am trying to change the update function for the pla

Can auto-vectorization be automatically done by #pragma omp simd? [duplicate]

In order to use auto-vectorization for a c++ code which will be running on x86-64 and aarch64 processors, is just adding #pragma omp simd in t