Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [c++17]

C++17 is the version of C++ after C++14. This tag should be used (along with the [C++] tag) for questions about C++ features specific to C++17

0 votes
0 answers
25 views

Extension of lifetime for inner fields when the type's lifetime is extended?

I am pondering about a piece of tooling code that we were using for a while here now, but which I suspect is actual undefined behaviour (at least, I got a couple of debugging sessions where it looks ...
Immanuel Scholz's user avatar
0 votes
0 answers
118 views

const char* vs std::string_view for constants [closed]

I usually use constexpr const char* for defining string constants. Of late, I have been noticing that std::string_view is very popular for this purpose. Which of these is the best? // 1. char pointer ...
0Nicholas's user avatar
  • 437
-3 votes
1 answer
50 views

Optimize memory in operators overload and template structures

The task: In this task you have to write a structure that will work both like a regular array in C and like a list in Python. Namely, write a structure template<typename T> struct FlexArray; ...
user26492712's user avatar
1 vote
0 answers
33 views

Unable to include thrust/host_vector.h and others with CUDA 12.5

This test program compiled fine with CUDA 12.4 and lower, but fails to compile w/ 12.5.1: #include <thrust/host_vector.h> #include <thrust/scan.h> #include <iostream> int main() { ...
Matt's user avatar
  • 20.6k
-1 votes
0 answers
50 views

<wx/wxprec.h> file not found [duplicate]

I've been trying to learn C++ and I started to learn about GUIs, but I've encountered some problems. I am using wxWidgets 3.2.5, downloaded it by source on the official website but I can't get It to ...
user22615570's user avatar
1 vote
1 answer
26 views

How to use void for std::conditional_t in C++17

I try to define the std::function template arguments of a class member based on a std::conditional_t type: template <class T, size_t N = 1> class MyClass { static_assert( (N > 0), "0 ...
moudi's user avatar
  • 518
1 vote
1 answer
80 views

How do I use std::reference_wrapper to store the reference in an std::unordered_map?

I'm trying to learn the use of std::reference_wrapper and std::ref and the use cases of it. Here is a sample code I wrote. Please help me solve the compilation error. And it would be great if you can ...
Aman Kumar's user avatar
-1 votes
1 answer
80 views

JNI CallStaticObjectMethod is causing crash with Java 21

The company I work for recently moved to Java 21 from Java 8, which updated the JNI version as well that is used with interoperatibility with C++. All the function (written in C++) called through JNI ...
StewieGGriffin's user avatar
-1 votes
0 answers
47 views

Matplot++- dealing with linker errors as a novice

I have installed matplot++ using vcpkg and compiled it with c++17. Working in visual studio 2022, I tried to copy a basic example from its github: #include <cmath> #include <matplot/matplot.h&...
Ron  Tubman's user avatar
1 vote
1 answer
80 views

What is error: expected unqualified-id before ‘(’ token?

I clone this open source project https://github.com/balfieri/cordic. I encountered issue below after following README to run $ g++ -std=c++17 -o test_basic test_basic.cpp $ g++ -std=c++17 -o ...
RookieRyan's user avatar
1 vote
0 answers
69 views

Argument passing and dangling pointers [duplicate]

I know that, in general, when calling a function, the evaluation of the arguments of the function call can happen in any order, but I'm in doubt about this particular situation (imagine T has a move ...
ABu's user avatar
  • 11.4k
1 vote
1 answer
90 views

Does early return of the same variable prevent NRVO?

Here is the code: std::vector<int> foo(bool cond) { std::vector<int> result; if (cond) { return result; // (1) } result.push_back(42); return result; ...
Dmitry Kuzminov's user avatar
4 votes
1 answer
110 views

correct syntax to access a template variable specialization

assume a template variable in data.h: template <class T> struct Data { Data() = delete; Data(T initValue) : value(initValue){} T value; }; template<class T> extern Data<T&...
Alexander's user avatar
  • 758
-2 votes
1 answer
50 views

C++ a single place to keep all #includes?

Gets a bit complicated with all #includes within each CPP file, is there a single place to keep all #includes?
espr3ss0's user avatar
2 votes
2 answers
63 views

Partial specialization of a class for pointer to members

I'm trying to create a function object where, given a pointer to a member, it calls std::hash of the pointed-to member (or the result of calling the function member), but there's something wrong about ...
ABu's user avatar
  • 11.4k

15 30 50 per page
1
2 3 4 5
743