Data dodania Pytanie
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
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