Data dodania Pytanie
2017-04-22 23:04 Guarantees of reordering of a vector »
Say I have this code: #include <iostream> #include <vector> int main() { std::vector<int> vec {10, 15, 20}; auto itr = ve...
(3) odpowiedzi
2017-04-20 23:04 Deducing class template arguments with a constructor that uses a member type alias »
So apparently this is supposed to work: template<class T> struct C { using value_type = T; C(value_type); }; C c(1); // C<int> A...
(2) odpowiedzi
2017-04-19 23:04 What is lub(null, Double)? »
Table 15.25-B in JLS version 8 says that the type of a conditional expression true ? null : 0.0 is lub(null,Double), where lub appears to be some c...
(2) odpowiedzi
2017-04-19 16:04 "Uninitialized captured reference" error when using lambdas in fold expression - clang vs gcc »
Consider the following code: template <typename F, typename X0, typename X1, typename... Xs> auto fold_left(F&& f, X0&& x0, X1&...
(1) odpowiedzi
2017-04-18 10:04 Why is a const variable sometimes not required to be captured in a lambda? »
Consider the following example: #include <cstdlib> int main() { const int m = 42; [] { m; }(); // OK const int n = std::rand(); ...
(3) odpowiedzi
2017-04-13 00:04 Which compiler, if any has a bug in parameter pack expansion? »
When experimenting with convenient ways to access tuples as containers, I wrote a test program. on clang (3.9.1, and apple clang) it compiles as expe...
(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-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-03-30 15:03 Lambda expression with empty capture »
I've encountered an interesting case (at least for me) when using lambdas and was wondering whether it is a compiler bug or something allowed by the s...
(1) odpowiedzi
2017-03-29 16:03 Is a statement void(); legal and what is it actually? »
I have a little piece of code which has a statement void(); int main() { void( ); // 1: parses fine in GCC 5.4.0 -Wpedantic // void; // 2:...
(2) odpowiedzi
2017-03-27 12:03 Can one use parameter value directly (not its type but value itself) in trailing return type syntax »
Consider the minimal example: template <int> struct bar { }; int main() { [](auto i) -> bar<i> { return {}; }; } Or even: te...
(2) odpowiedzi
2017-03-24 00:03 Cv-qualifications of prvalues in C++14 »
It appears that C++11 and C++14 treat cv-qualifications of prvalues differently. C++11 sticks to the "classic" approach that has been around since C+...
(1) odpowiedzi
2017-03-22 10:03 Manually constructing a trivial base class via placement-new »
Beware, we're skirting the dragon's lair. Consider the following two classes: struct Base { std::string const *str; }; struct Foo : Base { ...
(1) odpowiedzi
2017-03-21 13:03 The behaviour of floating point division by zero »
Consider #include <iostream> int main() { double a = 1.0 / 0; double b = -1.0 / 0; double c = 0.0 / 0; std::cout << a &lt...
(6) odpowiedzi
2017-03-17 10:03 What was the design rationale for making void not a primitive type? »
When using reflection Type.IsPrimitive on a void type returns false.Coming from a C++ background this was surprising. Looking at the C# 6.0 spec (Pag...
(3) odpowiedzi
2017-03-13 00:03 Is the Visual C++ implementation of std::async using a thread pool legal »
Visual C++ uses the Windows thread pool (Vista's CreateThreadpoolWork if available and QueueUserWorkItem if not) when calling std::async with std::lau...
(0) odpowiedzi
2017-03-12 22:03 What is the proper usage of a constexpr standard functor? »
Take the following code: #include <iostream> #include <functional> template <template<typename> class Op> auto applyOp(const...
(1) odpowiedzi
2017-03-11 15:03 mismatched std::allocator for some of STL containers »
Is it technically valid to use mismatched std::allocator specialization (surely, except it's specialization for void) as a template parameter for STL ...
(1) odpowiedzi
2017-03-03 20:03 Double brace initialization »
Which constructor should be called in the following code and why? struct S { int i; S() = default; S(void *) : i{1} { ; } }; S s{{}}; ...
(1) odpowiedzi
2017-02-28 19:02 I just can not understand DR 712 »
DR 712 was responsible for the change in the wording of [basic.def.odr]/2 in C++11 to the current wording today, in [basic.def.odr]2 and 3. But I'm st...
(2) odpowiedzi
2017-02-27 17:02 `type *var = (int)0`, legal or not? »
The following example: char *var = (int)0; Compiles on gcc and cl.exe, but causes an error in clang: cannot initialize a variable of type 'char...
(1) odpowiedzi
2017-02-26 04:02 Mysterious line in stack trace »
While investigating a stack trace discrepancy when composing another answer, I came across a behavior I do not understand. Consider the following test...
(1) odpowiedzi
2017-02-23 17:02 integral_constants in ternary operator »
MSVC and clang/gcc disagree on whether two different integral constants can be used in a ternary operator (and as a consequence whether they have a co...
(2) odpowiedzi
2017-02-23 16:02 `std::complex<T>[n]` and `T[n*2]` type aliasing »
Since C++11 std::complex<T>[n] is guaranteed to be aliasable as T[n*2], with well defined values. Which is exactly what one would expect for any...
(3) odpowiedzi
2017-02-20 15:02 Constructor reference - no warning when generics array is created »
In Java, it's not possible to create an array of generic type directly: Test<String>[] t1 = new Test<String>[10]; // Compile-time error ...
(3) odpowiedzi
2017-02-17 12:02 Does UINT_MAX have all bits set to 1? »
This question is asked before but I am still confused. I know that unsigned int a = -1; would be UINT_MAX. But it is not because all bits of -...
(3) odpowiedzi
2017-02-17 10:02 Managing trivial types »
I have found the intricacies of trivial types in C++ non-trivial to understand and hope someone can enlighten me on the following. Given type T, stor...
(2) odpowiedzi
2017-02-12 19:02 Why can't I use an brace-enclosed list as an operand to an overloaded operator? »
I'm working with a set of custom C++ libraries that provides a type representing a sequence. There's an overloaded operator+ that takes in two sequenc...
(0) odpowiedzi
2017-02-07 11:02 Lambda capture and parameter with same name - who shadows the other? (clang vs gcc) »
auto foo = "You're using g++!"; auto compiler_detector = [foo](auto foo) { std::puts(foo); }; compiler_detector("You're using clang++!"); clang++ 3...
(2) 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-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-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-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-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-26 11:01 Check if stream reference is NULL doesn't compile anymore »
I am compiling an outdated project with my latest gcc g++ compilers, (version > 6) There is a class CodeWriter with an ostream reference variable. c...
(3) odpowiedzi