Questions tagged [c++17]

2 votes
1 replies
`std::filesystem::path::operator/(/*args*/)` not working as expected
I have a class with an initialiser list in the constructor where one of the fields I'm initialising is a std::filesystem::path but it doesn't see...
asked 1 month ago
1 votes
1 replies
Create a C++ template function that will return an std::array of a specific size
I am creating a function titled linspase with C++17 with the following input structure linspace(double upper, double lower, int size). The funct...
asked 1 month ago
0 votes
0 replies
Attempting to compile C++17 filesystem library; get “version not found” [duplicate]
This question already has an answer here: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8' not found [cl...
asked 1 month ago
2 votes
2 replies
Find the unique elements of a vector C++
Is there a fast way to find all the single elements (only appeared once) in a vector of elements? All the elements in the vector is either single...
asked 1 month ago
0 votes
0 replies
Instantiating a C++ template function within a class causing compiler error [duplicate]
Quote from The C++ standard library: a tutorial and handbook: The only portable way of using templates at the moment is to implement them in...
asked 1 month ago
3 votes
1 replies
Same most-derived class in virtual inheritance = same offset between parent class?
For a certain class F, its pointer (created via new F()) can be up-cast to a base's class pointer e.g. to B*,C*,D* and E*. Is it guarant...
2 votes
1 replies
C++ template code generation Error: use of 'some_variable' before deduction of 'auto'
I ran into some issues with this specific code. The problem has most likely something to do with pointer to member of type Harry stored in a tupl...
1 votes
1 replies
Is it possible to avoid errors in parts of a c++ template function that are not going to run in the end?
I have a template with two integers as input. One may have a larger type than the other. My code does a shift accordingly so the results fits the...
-2 votes
2 replies
Structure padding with union members of std::bitset
After I had solved my issue to this question I went on to expand this version of my code to incorporate the unions of the data fields from my pre...
1 votes
1 replies
Failing to work around g++ 7.1 structured binding bug with Boost.Bimap
In my project I am using Boost.Bimap to implement bidirectional maps. Look at this very simple MCVE on godbolt, where I am using structured bind...
5 votes
1 replies
Using incomplete type in a member function of a class template
GCC (8.3, 9.1), Clang (7, 8) and MSVC (19.20) differ is their ability to compile this code: struct C; template<typename T> struct S {...
asked 1 month ago
0 votes
0 replies
Template Argument Deduction which function which is no where used/declared/defined [duplicate]
At http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx, the VC++ team officially declare that they have not yet implemented the C++11...
asked 1 month ago
7 votes
1 replies
Why does `polymorphic_allocator` take a `memory_resource` pointer and not a reference?
The C++17 Standard says: [mem.poly.allocator.ctor] polymorphic_allocator(memory_resource* r); Requires: r is non-null. Effects: Set...
asked 1 month ago
9 votes
0 replies
What type to use for a `constexpr` map?
Ideally I would like to write: constexpr std:map<std::string, std::string> my_map = {{"key1", "val1"}, {"key2", "val2"}, }; or const...
asked 1 month ago
5 votes
0 replies
Template-template, variadic template, and deduction guide: compiler bug?
Consider the following heavily templated code: // Preamble #include <list> #include <deque> #include <vector> #include <ios...
1 votes
1 replies
How do I replace std::binary_function with something else without pain?
We are currently using some 3rd party packages which use some std::binary_function, std::unary_function deep inside. As you might know, these fun...
2 votes
1 replies
Trying to flip the order of bits in std::bitset
I'm working on a structure that uses std::bitset and it looks like this: Register.h #pragma once #include <bitset> #include <vector&g...
asked 1 month ago
3 votes
2 replies
Sequencing between the destruction of local automatic function variables vs the construction of the return value
There exists code that relies on the fact that local automatic function variables are destroyed after the return value has been created, for exam...
asked 1 month ago
5 votes
2 replies
alias template for member template
let's say I have a template: template<typename T> struct Outer { template<typename T1> struct Inner { }; }; I'd like...
asked 1 month ago
0 votes
0 replies
g++ is failing “linker command failed with exit code 1” [duplicate]
This question already has an answer here: What is an undefined reference/unresolved external symbol error and how do I...
asked 1 month ago
5 votes
1 replies
Custom serialization of std::string_view causes unexpected compiler error
I've already asked this question on github (about a month ago), without any answer so I'm asking here now. I'm using Cereal as a serialization l...
asked 1 month ago
2 votes
1 replies
Using a level of indirection in a template SFINAE constraint causes a hard error
In the following code (https://wandbox.org/permlink/rA7lnXM6eQR4JhSM) #include <type_traits> template <typename T> struct Identity...
0 votes
1 replies
Get executable's path (with std::filesystem) [duplicate]
This question already has an answer here: Get path of executable 18 answers...
asked 1 month ago
-1 votes
0 replies
Why doesn't C++ provide default “copy-plus-allocator”? Missing feature?
I created a question (switching to another different custom allocator -> propagate to member fields), and found that, in every proposed soluti...
24 votes
5 replies
Is there an existing name for this type and function?
There are 2 hard problems in computer science: cache invalidation, naming things and off-by-one errors. This is about the 2nd problem: naming th...
asked 1 month ago