Data dodania Pytanie
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
2016-12-22 17:12 Must partitioningBy produce a map with entries for true and false? »
The partitioningBy collector applies a predicate to each element in a stream and produces a map from booleans to lists of elements from the stream tha...
(1) odpowiedzi
2016-12-22 13:12 Deleted constructor - MSVC reports an error, Clang doesn't »
Consider the following code: class SILPassPipelinePlan final { public: SILPassPipelinePlan() = default; ~SILPassPipelinePlan() = default; SILPa...
(2) odpowiedzi
2016-12-20 14:12 Neither clang nor g++ compile the snippet below. Why? »
Neither clang nor g++ compile this snippet: struct A{ protected: struct B{}; }; struct D: A::B, A{}; According to [class.access]/7, we hav...
(0) odpowiedzi
2016-12-15 11:12 Accessing generalize-captured objects in lambda trailing return type »
int main() { auto l = [x = 10]() -> decltype(x) {}; } clang++ 4.0 rejects this code with the following error: error: use of undeclared ...
(1) odpowiedzi
2016-12-14 14:12 Should the following code compile according to C++ standard? »
#include <type_traits> template <typename T> struct C; template<typename T1, typename T2> using first = T1; template <typename...
(2) odpowiedzi
2016-12-13 23:12 What's {} in void({})? »
Consider the following snippet: auto f() { return void({}); } int main() { f(); } What's exactly the {} in void({})? How is it interpreted? Just o...
(1) odpowiedzi
2016-12-09 15:12 What exactly is a "trailing parameter pack" »
In resolving ambiguities between function template overloads, partial ordering is performed (see here for some explanations). In that website, we also...
(2) odpowiedzi
2016-12-08 20:12 Ambiguous overload - partial function template ordering with parameter packs »
Consider the following contrived piece of code: template <class... > struct pack { }; template <class R, class T, class... Args> int foo...
(2) odpowiedzi
2016-12-01 14:12 Why is this expression being unsigneded? »
On x86_64 CentOS 7 GCC 4.8.5 C++11: #include <iostream> int main() { std::cout << ((ssize_t)1 - (size_t)5) << '\n'; } // Outp...
(1) odpowiedzi
2016-11-30 16:11 Class template specialization priority/ambiguity »
While trying to implement a few things relying on variadic templates, I stumbled accross something I cannot explain. I boiled down the problem to th...
(1) odpowiedzi
2016-11-29 19:11 reinterpret_cast creating a trivially default-constructible object »
cppreference† states that: Objects with trivial default constructors can be created by using reinterpret_cast on any suitably aligned stora...
(3) odpowiedzi
2016-11-28 11:11 Are checked guard parameter packs cause of ill-formed programs in case of specializations? »
This is a follow-up on this question. Consider the following code: #include <type_traits> template<typename T, typename... P, typename U =...
(1) odpowiedzi
2016-11-25 15:11 Does the C++ standard specify that for some cases the compiling should fail with an error? »
I answered a question, in which I said for a narrowing conversion an error should be triggered. Because the standard says: [ Note: As indicated ab...
(5) odpowiedzi
2016-11-23 13:11 Why can constructor syntax not be used with the "unsigned int" type? »
Why is the following illegal in C++? auto x = unsigned int(0); Whereas the following are all OK: auto y = int(0); auto z = unsigned(0); auto w = f...
(2) odpowiedzi
2016-11-20 17:11 Why does g++ fail init of std::function<> from type with conversion operator and inaccessible function call operators? »
This code fails with g++ 4.9 and later (including build from svn current,) but compiles without warning with clang++ and microsofts compiler (from VS2...
(3) odpowiedzi
2016-11-17 16:11 cast operator function compiles fine in g++ but not in other compilers. Why? »
Consider following program: struct S { using T = float; operator T() { return 9.9f; } }; int main() { S m; S::T t = m; t = m.oper...
(1) odpowiedzi
2016-11-13 19:11 structure tag in C vs C++ »
I wrote following simple program & compiled it on gcc compiler #include <stdio.h> typedef int i; void foo() { struct i {i i;} i; i....
(1) odpowiedzi
2016-11-12 11:11 Method references to multidimensional arrays in Java 8 »
In Java we may create IntFunction<String[]> from 1D array constructor reference: // both do the same thing IntFunction<String[]> ...
(2) odpowiedzi
2016-11-11 22:11 Is "template argument deduction for class templates" supposed to deduce empty parameter packs for variadic class templates? »
The "Template argument deduction for class templates" proposal (P0091R2) contains the following example: template<class ... Ts> struct X { X(Ts...
(1) odpowiedzi
2016-11-10 08:11 What is decltype(x) inside a lambda supposed to return when x is captured by reference? »
The following program compiles with trunk versions of Clang and GCC: #include <type_traits> auto main() -> int { auto x = 42; [&amp...
(0) odpowiedzi
2016-11-09 18:11 Using a parameter's name inside its own default value - is it legal? »
enum class E { One, Two }; void foo(E value = decltype(value)::One) { } It can be compiled with Clang (3.9), but cannot be compiled with GC...
(1) odpowiedzi
2016-11-03 18:11 Is this "if e is a pack, then get a template name, otherwise get a variable name" valid or not? »
I have tried to construct a case that requires no typename or template, but still yield a variable or template depending on whether a given name t is ...
(2) odpowiedzi
2016-10-30 02:10 In the CSS Visual Formatting Model, what does "the flow of an element" mean? »
In CSS2 Section 9.3: Positioning schemes: An element is called out of flow if it is floated, absolutely positioned, or is the root element. An ele...
(3) odpowiedzi
2016-10-26 14:10 Are C++14 digit separators allowed in user defined literals? »
While clang compiles the following line, g++ 6.1 complains about the digit separator (see live example on Coliru): auto time = 01'23s; Which compil...
(3) odpowiedzi
2016-10-26 10:10 Why is this a forward declaration in C++? »
I will have the following code snippet in utilA.cpp: // utilB.h namespace xm { void zoo(struct tm timeval); //<-----line 0 } // utilA.cpp ...
(2) odpowiedzi
2016-10-21 11:10 Is unevaluated division by 0 undefined behavior? »
I'm having a disagreement with some co-workers over the following code: int foo ( int a, int b ) { return b > 0 ? a / b : a; } Does this cod...
(4) odpowiedzi
2016-10-19 14:10 type of reference-captured object inside lambda »
The following code works with gcc #include <map> int main() { std::map<int, double> dict; const auto lambda = [&]() { ...
(1) odpowiedzi
2016-10-18 12:10 Using lambda in default initializer gcc vs clang »
#include <cassert> #include <cmath> int main() { struct point_of_cone { double x, y; double z = [&] { using s...
(1) odpowiedzi