Data dodania Pytanie
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
2017-01-26 07:01 Is it safe to use the address of a static local variable within a function template as a type identifier? »
I wish to create an alternative to std::type_index that does not require RTTI: template <typename T> int* type_id() { static int x; ret...
(4) odpowiedzi
2017-01-25 01:01 Why does one still need to disambiguate a dependent type with typename in the RHS of a using statement? »
I know very well why one needs to use typename for dependent types, since the compiler may not be able to disambiguate between a type and a variable d...
(0) odpowiedzi
2017-01-23 23:01 Does the standard state that copies must be equivalent? »
Suppose I have a weird string type, that either owns or doesn't own it's underlying buffer: class WeirdString { private: char* buffer; size_t...
(2) odpowiedzi
2017-01-22 01:01 Why does gcc reject `new v < new v` when `v` is not a template? »
Simple test case: #include <iostream> struct v {}; int main() { std::cout << __VERSION__ << '\n' << (new v < new v) &l...
(1) odpowiedzi
2017-01-21 13:01 Dynamic allocation of class array with protected destructor »
If I have a class defined like class A { protected: ~A(){ } }; then I can dynamically allocate the individual as well as array of objects like ...
(3) odpowiedzi
2017-01-20 18:01 VS2015 and clang compile this code, but g++ rejects it. Which one is correct? »
VS2015 and clang compile this code, but g++ rejects it. namespace A { struct B { friend void f(); }; } void A::f() {} int main(){ } I ...
(1) odpowiedzi
2017-01-19 17:01 Weird behavior with a manually defined strlen »
Accidentally, I wrote the following interesting snippet: #include <iostream> #include <cstring> size_t strlen(const char* str) { std...
(3) odpowiedzi
2017-01-18 14:01 Why does a lambda convert to a bool whose value is true? »
#include <iostream> void IsTrue(const bool value) { if (value) { std::cout << "value is True!\n"; } } int main() { IsTrue([]()...
(1) odpowiedzi
2017-01-17 23:01 Making `std::get` play nice with SFINAE »
std::get does not seem to be SFINAE-friendly, as shown by the following test case: template <class T, class C> auto foo(C &c) -> decltyp...
(3) odpowiedzi
2017-01-16 00:01 Does every c++ member function take `this` as an input implicitly? »
When we create a member function for a class in c++, it has an implicit extra argument that is a pointer to the calling object -- referred as this. I...
(4) odpowiedzi
2017-01-12 15:01 The 'this' pointer in the initialization list of the constructor »
I guess I am unable to understand why this is not working. I always thought that I can use 'this' pointer inside the constructor, but I never knew tha...
(2) odpowiedzi
2017-01-10 09:01 Evaluating stream operator >> as boolean »
The following code compiles in Visual Studio 2008 but fails in Visual Studio 2013 and later. std::string str("foo"); std::stringstream ss(str); float...
(1) odpowiedzi
2017-01-04 20:01 The first snippet below compiles, but the second doesn't. Why? »
The snippet below compiles (demo): struct A{ int i = 10; }; int main() { struct A{ int i = 20; }; struct A; struct A a; } But this doe...
(3) odpowiedzi
2016-12-28 10:12 Has there been a proposal to add std::bin to the c++ standard? »
C++14 adds ability to use binary literals by typing 0b prefix for the value: int v = 0b1111; // 15 in decimal But there is no std::bin manipulator ...
(1) odpowiedzi
2016-12-26 10:12 decltype deducted result of in-class defined function »
Why does struct MyStruct { auto foo () { return 1; } auto bar () { return foo(); } }; compile, but when using a trailing return type like so:...
(1) odpowiedzi