deleted-functions Questions
7
Solved
I've been working on some C++ code that a friend has written and I get the following error that I have never seen before when compiling with gcc4.6:
error: use of deleted function
‘GameFSM_<st...
Aurore asked 11/5, 2011 at 15:25
6
Solved
After reading this recent question by @Mehrdad on which classes should be made non-movable and therefore non-copyable, I starting wondering if there are use cases for a class which can be copied bu...
Pamella asked 14/1, 2013 at 17:4
3
Solved
I want to prevent certain functions from being called. Let's ignore the case of calling the function via a function pointer or something, and just concentrate on the case of direct function call. I...
Pochard asked 12/1, 2016 at 13:55
2
Solved
In the following example function f() returning incomplete type A is marked as deleted:
struct A;
A f() = delete;
It is accepted by GCC, but not in Clang, which complains:
error: incomplete result...
Tammietammuz asked 19/12, 2021 at 10:20
2
Solved
Qt defines Q_DISABLE_COPY as follows:
#define Q_DISABLE_COPY(Class) \
Class(const Class &) = delete;\
Class &operator=(const Class &) = delete;
Q_DISABLE_COPY is used in the QObject ...
Dorweiler asked 22/6, 2021 at 5:29
2
I'm trying to use the ExprTk mathematical expression parser library within a class whose objects are to be stored in a vector of objects, which is a member variable of another class; however, when ...
Pogge asked 15/10, 2020 at 17:50
1
There is a struct containing POD and default constructor deleted. Trying to aggregate-initalize an instance of the struct results in compilation error in g++9.1 when compiled with -std=c++2a....
Tribune asked 22/7, 2019 at 21:8
5
Solved
In order to make an object non-copiable we can explicitly delete both its copy-constructor and copy-assignment operator.
My question is: What is the right place to do it - in the public, private ...
Guthry asked 17/3, 2019 at 10:1
3
Solved
If I have an abstract base class and I want to make all derived classes noncopyable and nonmovable is it sufficient to declare these special member functions deleted in the base class? I want to en...
Loadstar asked 5/3, 2019 at 16:36
2
Solved
I have a class with a deleted move constructor and when I try to call std::vector::push_back() in MSVC (v.15.8.7 Visual C++ 2017) I get an error saying that I am trying to access the deleted move c...
Goldfinch asked 23/10, 2018 at 9:29
1
I'm unsure if the following code is valid according to the c++11 standard and should have the same behavior across different implementations or not:
#include <cstddef>
struct Foo{
template ...
Preventive asked 23/11, 2016 at 14:30
2
Solved
Recently, I came across this answer which describes how to initialize a std::array of non-default-constructible elements. I was not so surprised because that answer clearly doesn't do any default-c...
Almita asked 20/7, 2018 at 13:24
2
Solved
Say I have this structure:
struct F
{
int& ref; // reference member
const int c; // const member
// F::F() is implicitly defined as deleted
};
That is from cppreference. As I understand f...
Erine asked 1/5, 2018 at 7:42
1
Solved
I wonder why this program doesn't compile (the same behavior on msvc, gcc and clang):
#include <iostream>
using namespace std;
struct Action
{
virtual void action()
{
cout << "Act...
Greasy asked 8/3, 2018 at 12:56
4
Solved
How can I initialize an array without copy or move-constructing temporary elements? When the element has an explicitly deleted copy or move constructor, I can initialize the array only if the eleme...
Intravasation asked 18/2, 2017 at 0:3
1
Solved
Consider these two possible definitions for a class:
Exhibit A:
struct A
{
A() = delete;
};
Exhibit A′:
struct A
{
A() noexcept = delete;
}
Is there any point in declaring a deleted functi...
Vanda asked 9/7, 2016 at 7:15
3
Solved
According to the standard,
If the definition of a class X does not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if
— X does not have a user-decla...
Guillotine asked 17/5, 2016 at 12:36
2
Solved
I have a use case that my object must not be copied in any way. I have written an exaggerated complete list of copy constructor and copy assignment operator deletions below. There are so many of th...
Stavanger asked 18/11, 2015 at 9:51
1
Solved
Compiling a project with an older version of g++ (4.8.0, MinGW) I found that this code fails to compile:
template<typename T>
void foo() = delete;
template<>
void foo<int>(){}
...
Whitebait asked 21/10, 2015 at 10:12
1
I am using g++ 5.1.0 to compile the following C++14 program test.cpp:
#include <memory>
class Factor {
public:
Factor(const Factor&) = default;
Factor(Factor&&) = default;
F...
Stylograph asked 4/10, 2015 at 22:7
4
Solved
I need help with the non-copyable nature of [io](f)streams.
I need to provide a hackish wrapper around fstreams in order to handle files with unicode characters in their filenames on Windows. For ...
Conjoined asked 29/6, 2011 at 17:31
3
Solved
I originally posted this as a question only about destructors, but now I'm adding consideration of the default constructor. Here's the original question:
If I want to give my class a destructor ...
Popele asked 27/11, 2012 at 1:25
3
Solved
I'm new to game development and very new to c++, but I've started developing a little Arkanoid game. I've had it running previously, but after refactoring (introducing the ArkanoidGame class) it do...
Zaid asked 28/1, 2014 at 15:14
4
Solved
I am trying to clear a std::queue using the example in https://mcmap.net/q/125727/-how-do-i-clear-the-std-queue-efficiently via a swap. However, it doesn't seem to work with a lambda comparator due...
Seafaring asked 23/12, 2013 at 20:26
1
struct A
{
A(int x)
: n(x)
{}
A(A&&)
{}
A& operator =(A&&)
{
return *this;
}
int n;
};
int main()
{
A a(1), b(2);
a = b;
if (2 == a.n)
{
// It SHOULD go her...
Saprophyte asked 9/10, 2013 at 8:48
1 Next >
© 2022 - 2024 — McMap. All rights reserved.