Data dodania Pytanie
2017-02-06 21:02 Why is my swap<string,string> far slower than the std version? »
This is my C++ code: inline static void swap(std::string& a1, std::string& a2) { std::string temp( std::move(a1)); a1 = std::move...
(1) odpowiedzi
2017-02-06 21:02 Why this ADL case is working? »
How does find_type know where the function typemap is? The argument it receives is not from that namespace, it's from the std namespace! #include &lt...
(2) odpowiedzi
2017-02-06 12:02 Is constructed string("Plain Old C chain") a rvalue? »
I was wondering if a copy elision is made in the call of foo(string) below. (Note: foo(string) belongs to an interface that I can not change). For th...
(2) odpowiedzi
2017-02-06 08:02 C++ Multithreading: is initialization of a local static lambda thread safe? »
The C++11 standard says about local static variable initialization that it is supposed to be thread safe (http://en.cppreference.com/w/cpp/language/st...
(3) odpowiedzi
2017-02-05 12:02 Why does C++ allow you to move classes containing objects with deleted move operations? »
Why am I allowed to use std::move on a class which contains fields of a type with deleted move semantics (case 1), but am not allowed to use it on an ...
(1) odpowiedzi
2017-02-05 06:02 Does the defaulted default constructor initialize variables to zero? »
I'm updating a class to C++14, and trying to figure out the simplest way to initialize all of the instance variables to zero on construction. Here's w...
(2) odpowiedzi
2017-02-05 05:02 Why is a template<typename...> not recognized as instantiatable through template<template<typename> typename>? »
I'm trying to arbitrarily "bind" template parameters but have run into an elegance problem. To cut straight to the underlying problem, gcc 6.2 has a ...
(2) odpowiedzi
2017-02-05 02:02 How to check if a 2d array is in ascending order in c++? »
I can't get this function to return true, despite the fact that I've initialized the array in ascending order. bool won(int gameBoard[][SIZE]) { ...
(2) odpowiedzi
2017-02-04 17:02 C++ template partial specialization: Why cant I match the last type in variadic-template? »
I try to write a IsLast type traits to check if a given type is the last one in a std::tuple, but the code below does not compile. I know how to get a...
(4) odpowiedzi
2017-02-04 17:02 Is it possible to create a trait to answer if a type comes from std? »
After this question by utilizing ADL one can create a trait to answer if the passed type comes from our namespace: #include <utility> namespac...
(1) odpowiedzi
2017-02-04 08:02 What is the correct result of decltype( (A{}.int_member) )? »
Given the definition of type A : struct A { int i; }; According to the specification [expr.ref] (I used n4618) : (if E2 is non-reference,) ...I...
(1) odpowiedzi
2017-02-03 19:02 Accidentially 'instantiate' an abstract class type using brace-initializers? »
Today I stumbled over the following issue. Someone got a little too fond of brace-initializers and accidentally tried to instantiate an interface clas...
(1) odpowiedzi
2017-02-03 10:02 Is the following an undefined behavior? i = func(i) »
I know that i=i++; is an undefined behavior, because i is changed twice before the sequence point ;. But I don't know if the compiler guarantees the ...
(1) odpowiedzi
2017-02-03 09:02 How to ensure that every method of a class calls some other method first? »
I have : class Foo { public: void log() { } void a() { log(); } void b() { log(); } }; Is ther...
(6) odpowiedzi
2017-02-02 19:02 Get the return type of begin on a c array »
I would like to get the return type of std::begin in a generic way. My current solution is: using type = decltype(std::begin(std::declval<T>())...
(1) odpowiedzi
2017-02-02 19:02 Is having a function header that return an abstract type legal? »
I was wondering of the following was legal according to the C++ standard: struct Abstract { virtual ~Abstract() = 0; }; auto get_type() -> Abstra...
(1) odpowiedzi
2017-02-02 08:02 Why is std::is_const::value 'false' even though T's value_type is const? »
#include <type_traits> struct foo; int main() { const foo *bar; static_assert(std::is_const<decltype(*bar)>::value, ...
(1) odpowiedzi
2017-02-01 21:02 In C++, is exactly one of <, == and > guaranteed to be true on floats? »
In C++, do I have a guarantee that, for any given float a and float b, one and only one of a < b, a == b and a > b is true? If this differs bet...
(1) odpowiedzi
2017-02-01 17:02 Why are there so many specializations of std::swap? »
While looking at the documentation for std::swap, I see a lot of specializations. It looks like every STL container, as well as many other std facilit...
(6) odpowiedzi
2017-02-01 16:02 Best way to eliminate deprecated conversion from string constant to ‘char*’" »
I have came across a situation as follows and I am getting following warning from the compiler. Main.cpp:14:22: warning: deprecated conversion fr...
(3) odpowiedzi
2017-02-01 14:02 Stop double division before decimals (low precision, fast division; getting only the 'quotient') »
Basically a performance related question: I want to get only the integer quotient from a double division, i.e. for example, for a division 88.3/12.7 ...
(1) odpowiedzi
2017-02-01 09:02 Objects that can be initialized but not assigned »
I need to create a class whose objects can be initialized but not assigned. I thought maybe I could do this by not defining the assignment operator, ...
(5) odpowiedzi
2017-01-31 18:01 XOR Operation Intuition »
I recently came across this question on Leetcode and figured out a solution that I need some clarification with: Given an array of integers, every...
(6) odpowiedzi
2017-01-31 15:01 Why am I getting an unused lambda capture warning? »
I am passing a lambda with an init-captured loop counter like this: #include <iostream> auto sq(int c, int x) { return c * x * x; } struct S ...
(1) odpowiedzi
2017-01-31 12:01 `pair::operator=(pair&&)` error with `auto&` deduced move operations - libstdc++ regression? »
Given this program: struct Val { Val() = default; Val(Val&&) = default; auto& operator=(Val&&); }; /* PLACEHOLDER */...
(1) odpowiedzi
2017-01-30 22:01 Differences in the initialization of the EAX register when calling a function in C and C++ »
There is a curious difference between assemblies of a small program, when compiled as a C-program or as a C++-program (for Linux x86-64). The code i...
(1) odpowiedzi
2017-01-30 18:01 C - What does x+1 means without assignment? »
My question is maybe very simple, but I'm wondering what does this x+1 means? Let's see an example: int main() { int x = 2; x + 1; //1 i...
(4) odpowiedzi
2017-01-30 10:01 How to check if every type in a parameter pack is unique? »
For a fixed number of template parameters it is easy, although the number of manually written checks grows quadratically. #include <type_traits&gt...
(1) odpowiedzi
2017-01-29 14:01 Should I pass allocator as a function parameter? (my misunderstanding about allocator) »
After I am studying about allocator for a few days by reading some articles (cppreference and Are we out of memory) , I am confused about how to contr...
(2) odpowiedzi
2017-01-29 13:01 Pass lambda as template function parameter »
Why doesn't the following code compile (in C++11 mode)? #include <vector> template<typename From, typename To> void qux(const std::vecto...
(6) odpowiedzi
2017-01-29 01:01 Why are non underscore names reserved to the implementation for UDL and not the other way around? »
I know this is an old feature but reading on user defined literals e.g. return_t operator "" _a(long); // Literal operator for user-defined INTEGRAL ...
(1) odpowiedzi
2017-01-28 23:01 Getting ECL symbol name as string in C++ »
I'm working on embedding Embeddable Common Lisp into a library and I've been writing utility functions to convert ECL's cl_object to various C/C++ typ...
(1) odpowiedzi
2017-01-28 19:01 How can I declare a member vector of the same class? »
Why on earth this piece of code works: struct A { std::vector<A> subAs; }; A is an incomplete type right? if there was a vector of A*s I ...
(2) odpowiedzi
2017-01-28 16:01 Pre-processor parsing on C++ »
If we want to use user input to do something in a program, or print a result we need to #include <iostream> otherwise, cout and cin will no...
(4) odpowiedzi
2017-01-28 15:01 Where is the return object stored? »
I generally understand how a function returns an object by value. But I wanted to understand it on the lower level. Assembly level if reasonable. I u...
(3) odpowiedzi