Data dodania Pytanie
2017-10-11 11:10 GCC : Unscoped enumeration type give an ambiguity error »
In the following code, I have defined an unscoped enumeration with long long type. This program works fine on Clang. But GCC compiler gives an ambigu...
(1) odpowiedzi
2017-10-09 14:10 Does shared_ptr still own its object when calling the deleter? »
I have a std::shared_ptr with a custom deleter and in that deleter, I would like to take a temporary copy of the original std::shared_ptr. Expressed i...
(1) odpowiedzi
2017-10-07 20:10 Are user defined deduction guides involving template template parameter as a template for guidance standard compliant »
Background Yesterday I asked a question about the guarantees of deduction guides usage in case of template template parameters. I was really surprise...
(0) odpowiedzi
2017-10-06 18:10 Is it guaranteed that template template parameter invoke user provided deduction guides »
Consider an example: #include <type_traits> #include <string> template <template <class> class TT> //#1 struct Foo { stat...
(1) odpowiedzi
2017-10-04 02:10 Partial template specialization with mismatching `int` and `size_t` not compiling »
With reference to the following code #include <utility> #include <cassert> template <typename T> struct Wot; template <int... ...
(1) odpowiedzi
2017-10-01 14:10 Why doesn't an if constexpr make this core constant expression error dissappear? »
In reference to this question. The core constant expression that is used to initialize the constexpr variable y is ill-formed. So much is a given. Bu...
(3) odpowiedzi
2017-09-28 15:09 Is everything after an exporting namespace not exported? »
I was reading about modules, and I wished to do something like this: a.cpp module foo.a; export namespace foo { struct A { void doA(); ...
(0) odpowiedzi
2017-09-24 09:09 Can bitwise operators have undefined behavior? »
Bitwise operators (~, &, | and ^) operate on the bitwise representation of their promoted operands. Can such operations cause undefined behavior? ...
(1) odpowiedzi
2017-09-16 14:09 If structured bindings cannot be constexpr why can they be used in constexpr function? »
According to this answer apparently there is no good reason why structured bindings are not allowed to be constexpr, yet the standard still forbids it...
(2) odpowiedzi
2017-09-15 16:09 Can't understand name lookup differences between an int and a user defined type - perhaps ADL related »
Why does the following code compile: template<typename T> void foo(T in) { bar(in); } struct type{}; void bar(type) {} int main() { foo(type()...
(2) odpowiedzi
2017-09-09 18:09 Does std::vector::reserve guarantee that the implementation will not invalidate iterators in this case? »
Here is a function which intends to: a) accept a vector of int b) for each int in the input vector, append the inverse of this int preconditions: n...
(2) odpowiedzi
2017-09-08 14:09 overload resolution between lvalue reference and rvalue reference »
#include <iostream> using namespace std; void func(int (&ref)[6]) { cout << "#1" << endl; } void func(int * &&ref) { c...
(1) odpowiedzi
2017-09-05 13:09 Can constructor template cause ambiguity in the c++17 parameter deduction of class template »
Consider a simple example: template <class T> struct foo { template <template <class> class TT> foo(TT<T>&&) ...
(2) odpowiedzi
2017-09-03 21:09 Can non-type template parameters in c++17 be decltype(auto)? »
I discovered that gcc and clang allow to use decltype(auto) in non-type template parameter type clause. E.g.: template <decltype(auto)> struct ...
(1) odpowiedzi
2017-09-03 07:09 c++11 decltype(e) is the type of the entity named by e »
I am not asking decltype((x)), I know how it works. According to the draft N4687, § 10.1.7.2 4 For an expression e, the type denoted by declty...
(3) odpowiedzi
2017-09-02 11:09 Using C++ shared pointer's aliasing constructor with an empty shared pointer »
std::shared_ptr has an aliasing constructor that allows newly created shared_ptr to share state with an existing shared pointer while pointing to some...
(1) odpowiedzi
2017-08-29 13:08 Why was getenv standardised but not setenv? »
From answers and comments on this question, I understand that getenv is defined by the C++ standard, but setenv is not. And indeed, the following prog...
(2) odpowiedzi
2017-08-27 18:08 Russell's paradox in C++ templates »
Consider this program: #include <iostream> #include <type_traits> using namespace std; struct russell { template <typename barbe...
(1) odpowiedzi
2017-08-24 18:08 RVO overwriting value in parameter before return »
Compiling the following with xlC on AIX results in code that prints "2 2". On Linux with gcc and clang it reliably produces "3 3". #include <iostr...
(1) odpowiedzi
2017-08-22 10:08 Inherited constructors ignore in-class initialization »
I have a class defined like this: class ASTConcatenateLiteral : public ASTExpr { using ASTExpr::ASTExpr; private: Type type_ = Type::nothingn...
(2) odpowiedzi
2017-08-21 08:08 template template parameters and forwarding references »
Suppose we have the following code: template<typename T> class C {}; template <typename T, template <typename> class Container> vo...
(2) odpowiedzi
2017-08-19 12:08 Is there any difference with undefined behaviour between iterator and scalar object? »
The topic about evaluation order says that following code leads to undefined behavior until C++17: a[i] = i++; This happens due to unspecified orde...
(1) odpowiedzi
2017-08-18 09:08 Can we place "typedef" specifier anywhere in the declaration? »
The syntax of typedef specifier : typedef <existing_name> <alias_name> for example: typedef long unsigned int Int; It's working fine...
(2) odpowiedzi
2017-08-11 06:08 std::promise set_value and thread safety »
I'm a bit confused about the requirements in terms of thread-safety placed on std::promise::set_value(). The standard says: Effects: Atomically s...
(2) odpowiedzi
2017-08-08 08:08 Is copy/move elision allowed when returning *&object? »
Look at this code: #include <stdio.h> struct Foo { Foo() { } Foo(const Foo &) { printf("copy\n"); } Foo(Foo &&) { prin...
(1) odpowiedzi
2017-08-07 19:08 C++17 And the Current State of Decimal Floating Point »
What is the current status of decimal floating point in C++? I am specifically looking for the status of language inclusion, standards compliance and...
(1) odpowiedzi
2017-08-06 14:08 Why does this rvalue reference bind to an lvalue? »
I do not understand why the following code compiles on GCC 8.0: decltype(auto) foo(int&& r) { return r; } In foo, the declaration type ...
(1) odpowiedzi
2017-08-05 08:08 Special behavior for decltype of call operator for incomplete types »
I've been struggling with a compilation issue, and have been able to shrink the problem down to a small code segment. To set the stage, I'm trying to...
(1) odpowiedzi
2017-08-04 14:08 Consequences of uninitialised variables: int vs unsigned char »
I saw the following example on cppreference.com int x; // OK: the value of x is indeterminate int y = x; // undefined behavio...
(4) odpowiedzi
2017-08-02 10:08 Is this a clang bug or something I don't know about C++? »
While looking at this question I tried it out with clang and got in a weird situation. The following example: #include <string> class ACP { pu...
(1) odpowiedzi
2017-07-26 18:07 Are structs of variables of the same type layout compatible with a struct containing an array of that type? »
Are these 2 structs layout-compatible? struct One { float x, y, z; }; struct Two { float c[3]; }; Both contains 3 floats, so in a way, thi...
(2) odpowiedzi
2017-07-23 17:07 Why disallow goto in constexpr functions? »
C++14 has rules for what you can and can't do in a constexpr function. Some of them (no asm, no static variables) seem pretty reasonable. But the Stan...
(2) odpowiedzi
2017-07-22 13:07 Why do std::generate() and std::generate_n() require different iterators? »
I was looking at generate() and generate_n() in cppreference and am trying to understand why does generate() require ForwardIterator, whereas generate...
(3) odpowiedzi
2017-07-20 16:07 Does std::map assign its comparator? »
Is std::map copy assignment (in style map1 = map2;) required to copy comparator of map2 to map1? I have tested that actual implementations do that. ...
(2) odpowiedzi
2017-07-18 21:07 Is std::to_string thread safe? »
I am looking to convert integer types to string using std::to_string, but I saw this paragraph: std::to_string relies on std::locale for formattin...
(1) odpowiedzi