defaulted-functions Questions
1
C++20 has made it possible to default comparison operators, including the three-way comparison like this. <=> can have a deduced return type, but other operators can't:
struct S {
friend aut...
Obstruent asked 13/9, 2023 at 10:57
1
Solved
Clang compiles this fine, but GCC and MSVC complain that operator= cannot be defaulted:
#include <type_traits>
template<class T>
struct S
{
typedef typename std::enable_if<!std::is...
Ratty asked 11/12, 2021 at 21:13
2
Solved
cppreference shows the following definition of std::in_place_t:
struct in_place_t {
explicit in_place_t() = default;
};
inline constexpr std::in_place_t in_place{};
Why have they added an expli...
Primordial asked 18/3, 2019 at 15:56
8
Solved
C++11 adds the ability for telling the compiler to create a default implementation of any of the special member functions. While I can see the value of deleting a function, where's the value of exp...
Desmond asked 5/5, 2009 at 8:49
1
Solved
I found it quite odd that the following program still compiled fine despite the default constructor being private (4.8.1 g++):
class A{
private:
A() = default;
A(const A&) = default;
};
...
Lipoid asked 16/10, 2015 at 21:52
2
Solved
Some days ago, while reading Standard C++ news I've read the post about Defaulted functions in C++11, in that article is mentioned that the user-defined constructor is less efficient than the one g...
Disorient asked 5/6, 2013 at 13:33
1
Solved
GCC 4.5 doesn't let me do this:
class foo {
public:
foo() = default;
private:
foo(foo const&) = default;
foo& operator=(foo const&) = default;
};
It complains that:
error: 'fo...
Adeliaadelice asked 29/8, 2011 at 0:18
2
Solved
C++0x lets you specify certain functions as defaulted:
struct A {
A() = default; // default ctor
A(A const&) = default; // copy ctor
A(A&&) = default; // move ctor
A(Other); // oth...
Berezina asked 27/9, 2010 at 14:56
1
© 2022 - 2024 — McMap. All rights reserved.