Data dodania Pytanie
2017-04-12 08:04 Confusion about auto keyword »
I'm confused by the following piece of code: #include <iostream> using namespace std; int *foo() { //Operation } int main () { aut...
(4) odpowiedzi
2017-04-11 15:04 Optimize for a specific machine / processor architecture »
In this highly voted answer to a question on the performance differences between C++ and Java I learn that the JIT compiler is sometimes able to optim...
(2) odpowiedzi
2017-04-11 15:04 When an automatic variable get out of scope, in what order operations occurs? »
I'm building a simple { mutex, value } pair as follows, and I'd like to check with c++ lawyers if my use case is well defined. Tool definition templ...
(0) odpowiedzi
2017-04-11 05:04 Why does C++ standard specify signed integer be cast to unsigned in binary operations with mixed signedness? »
The C and C++ standards stipulate that, in binary operations between a signed and an unsigned integer of the same rank, the signed integer is cast to ...
(3) odpowiedzi
2017-04-10 10:04 Are the experimental features of modern C++ reliable for long-term projects? »
I have a project that currently uses C++11/14, but it requires something like std::filesystem, which is only available in C++17, and hence I don't hav...
(4) odpowiedzi
2017-04-10 08:04 What is the C++17 equivalent to boost::filesystem::unique_path()? »
std::filesystem on C++17, and std::experimental::filesystem for many pre-C++17 compilers, are based on boost::filesystem and almost all of it is obvio...
(2) odpowiedzi
2017-04-10 00:04 Generic utility to create aribtrary tuples of integral_constants »
Making use of Scott Schurr's str_const I have a constexpr string. class StrConst { public: template<size_t N> constexpr StrConst(const ...
(3) odpowiedzi
2017-04-09 14:04 Can std::cin fail to pass a user input in the command line to a variable with a type of char? »
I have tried passing different inputs with the below code, but have failed to get the message printed: "Oops, you did not enter an ASCII char, let alo...
(1) odpowiedzi
2017-04-09 11:04 Why is creating shared_ptr from unique_ptr of array not allowed anymore? »
From cppreference: In C++11 and C++14 it is valid to construct a std::shared_ptr<T> from a std::unique_ptr<T[]>: std::unique_ptr&lt...
(1) odpowiedzi
2017-04-09 06:04 Why does GCC call libc's sqrt() without using its result? »
Using GCC 6.3, the following C++ code: #include <cmath> #include <iostream> void norm(double r, double i) { double n = std::sqrt(r *...
(1) odpowiedzi
2017-04-08 21:04 std::map implementation differs between linux and windows »
The following code acts differently after being compiled in linux and Visual Studio 2015. #include <map> #include <iostream> using namesp...
(1) odpowiedzi
2017-04-08 19:04 g++ handling of copying a std::complex »
As part of a self-education project I looked into how g++ handles std::complex - type and was puzzled by this simple function: #include <complex&...
(1) odpowiedzi
2017-04-08 12:04 Is std::byte in C++ 17 equivalent to byte in C#? »
I just noticed std::byte in the C++ 17. I am asking this question because I use the code below to send byte array to C++ to play audio sound. C#: [...
(2) odpowiedzi
2017-04-08 06:04 Where do normal templates end and meta templates begin? »
Jörg's answer to this question nicely delineates between "normal" templates (what the question refers to, perhaps erroneously, as generics) which ope...
(4) odpowiedzi
2017-04-07 19:04 Why is the compiler optimizing these cases differently? »
The snippet of code found below demonstrates a situation in which calling the CRC32 compiler intrinsic on 7 bytes of data in two different ways (e.g. ...
(1) odpowiedzi
2017-04-07 16:04 Using "using" in public to inherit private constructor does not make it public »
"using" a private member variable makes it a public member but the constructor stays private. Example: class MyClass; class Base { private: Ba...
(1) odpowiedzi
2017-04-07 14:04 Order of assignment with post increment »
I have the following expression while(i < 10) { out[i++] = in[i]; } Is the point, at which i is incremented, specified in the C++ STD? All ...
(0) odpowiedzi
2017-04-07 10:04 C++ emplace_back parameters »
Here is a piece of code in my daily work. I just want to ask you if there is any difference between the two cases, especially in terms of performance....
(1) odpowiedzi
2017-04-07 04:04 In using-declaration, can dependent names render to constructors after template substitution? »
In this example: template<class T> struct S : T { using T::X; }; T::X is a dependent name that refers to the member X in T. If S<T>...
(1) odpowiedzi
2017-04-06 20:04 Why is '--++a-​- ++ +b--' evaluated in this order? »
Why does the following print bD aD aB aA aC aU instead of aD aB aA aC bD aU? In other words, why is b-- evaluated before --++a--++? #include <iost...
(5) odpowiedzi
2017-04-06 15:04 g++ undefined reference although symbol is present in *.so file »
I found a number of similar questions (e.g. this, that or this), but none of them helped me solve my problem. I have a *.so file (from the core of gns...
(2) odpowiedzi
2017-04-06 13:04 Why do C++ templates use the angle bracket syntax? »
The titular question refers to the design decisions in the C++ standard that introduced templates around 1990. Why did the designers use <> (a...
(1) odpowiedzi
2017-04-05 17:04 Moving list<unique_ptr> into vector attempts to reference a deleted function »
Here is a complete program which reproduces my problem. #include <vector> #include <list> #include <memory> #include <utility&gt...
(1) odpowiedzi
2017-04-05 16:04 Aggregate initialization of a struct, using its own data members »
This is the n-th question about this, but I couldn't find exact duplicate... Suppose the following code: #include <iostream> struct S { i...
(2) odpowiedzi
2017-04-05 12:04 Return with assert and comma operator »
http://en.cppreference.com/w/cpp/algorithm/clamp gives this as a possible implementation for std::clamp: template<class T, class Compare> const...
(1) odpowiedzi
2017-04-05 04:04 Multi-tier namespace specification in C++ »
A client of mine has coding standards that call for namespaces need to be defined with all individual names and braces on separate lines. This leads t...
(1) odpowiedzi
2017-04-04 21:04 Defining fstream inside a 'if' conditional »
In an answer there was the following code: if (std::ifstream input("input_file.txt")) ; Which seems convenient, limiting the scope of the 'input'...
(2) odpowiedzi
2017-04-04 19:04 Why is gcc failing when using lambda for non-type template parameter? »
The following snippet compiles with no error with Clang 4.0 but GCC 7.0 produces errors (note the use of -std=c++1z flag). using FuncT = int (*)(dou...
(2) odpowiedzi
2017-04-04 15:04 Choosing the proper type name »
Let's say I have the vector of strings, is there any preferable way of naming this type? Are there any cons or pros on choosing names like: using s...
(1) odpowiedzi
2017-04-04 10:04 If statement vs if-else statement, which is faster? »
I argued with a friend the other day about those two snippets. Which is faster and why ? value = 5; if (condition) { value = 6; } and: if (con...
(7) odpowiedzi
2017-04-04 06:04 How to prevent clang-format from adding a single semicolon to a new line? »
I have this line of code in C++ while (fread(pixel_array++, sizeof(byte), 3, fp)); but when I use clang-format, it splits the semicolon and add it ...
(1) odpowiedzi
2017-04-03 19:04 C++ Order of Precedence with a Seemingly Nonsense Output: »
int main() { int a =5; cout << a-- << ' '; cout << a << ' '; cout << a-- << ' ' << a-- << ' '; c...
(0) odpowiedzi
2017-04-03 14:04 How to properly throw an exception which needs more than just a constructor? »
I have an Exception class on which I want to set more information before I throw it. Can I create the Exception object, call some of its functions and...
(3) odpowiedzi
2017-04-03 13:04 Why is C array so much faster than std::array? »
We are currently writing some performance critical code in C++ that operates on many large matrices and vectors. Regarding to our research, there shou...
(2) odpowiedzi
2017-04-03 11:04 C++ variadic template with doubles »
The following code #include <initializer_list> #include <vector> template<int ...> const std::vector<int>*make_from_ints(in...
(1) odpowiedzi