noncopyable Questions
1
Solved
Consider the following code. In order for this to compile, I HAVE to provide a body for the move constructor. Having "TestClass(TestClass&& other) = default" does not compile with...
Merman asked 16/12, 2022 at 16:8
3
Solved
I need a container of elements that are neither copyable nor movable. These elements are not default constructible, but their constructors get identical arguments.
The size of the container does ...
Roundhead asked 29/9, 2016 at 12:50
10
I'm looking for the best-practice of dealing with non-copyable objects.
I have a mutex class, that obviously should not be copyable.
I added a private copy constructor to enforce that.
That broke...
Scroggins asked 11/8, 2010 at 10:44
6
Solved
Adding any noncopyable member to a class would prevent the automatic generation of copy construction and assignment operator. Why does boost require inheritance to use noncopyable?
I think I am no...
Lindner asked 28/1, 2011 at 15:7
2
Solved
Have a look at the following code:
#include <utility>
#include <map>
// non-copyable but movable
struct non_copyable {
non_copyable() = default;
non_copyable(non_copyable&&...
Manilla asked 16/2, 2013 at 23:51
3
I'd like to initialize a static std::map where the value is not copyable. I'll call my class ValueClass. ValueClass has an std::unique_ptr as private member and I even ensure that ValueClass is not...
Sparoid asked 16/12, 2018 at 21:35
3
Solved
If we have a container with non-copyable value type, such a container class still defines the copy constructor, just it may not be invoked.
using T = std::vector<std::unique_ptr<int>>;...
Implicative asked 8/11, 2018 at 14:51
10
Solved
See title.
I have:
class Foo {
private:
Foo();
public:
static Foo* create();
}
What need I do from here to make Foo un-copyable?
Other asked 31/1, 2010 at 22:59
4
Solved
According to my favorite author , Mr Scott Meyers, the private inheritance and composition means the same thing aka Has-A relationship. Thus everything that can be gained from composition (containm...
Sheelah asked 4/6, 2018 at 12:13
3
Solved
I have a (third-party) class which is non-copyable. I'd like to initialize an array of them. Here's my best attempt:
#include <array>
class Thing
{
public:
explicit Thing(int) {}
Thing(co...
Galvani asked 8/4, 2014 at 3:29
6
Solved
i've been searching on google and stackoverflow for 2hours now. There has to be something i am just simply overlooking. Is there an easy way to make the text selectable in a messagebox? As of right...
V asked 20/10, 2011 at 18:11
6
Assume I have a non-copyable class with multiple constructors with like this
class Foo: boost::noncopyable
{
public:
Foo(std::string s) {...}; // construct one way
Foo(int i) {...}; // constru...
Yearn asked 29/5, 2014 at 12:11
1
Solved
I want my class to hold a v8::Context and a v8::External as members. Therefore, I thought I had to use persistent handles.
class ScriptHelper {
public:
ScriptHelper(v8::Persistent<v8::Context&...
Append asked 25/3, 2014 at 21:22
1
Solved
In Qt there is a macro that allows declaring private copy constructurs and assignment operators for classes: http://qt-project.org/doc/qt-5.0/qtcore/qobject.html#Q_DISABLE_COPY
It is said that thi...
Parsifal asked 8/11, 2013 at 8:15
11
Solved
To prevent copying a class, you can very easily declare a private copy constructor / assignment operators. But you can also inherit boost::noncopyable.
What are the advantages / disadvantages of u...
Addict asked 19/10, 2011 at 15:40
5
Solved
With explicitly deleted member functions in C++11, is it still worthwhile to inherit from a noncopyable base class?
I'm talking about the trick where you privately inherit a base class which has p...
Distorted asked 27/2, 2012 at 0:40
1
Solved
What should I do to initialize boost::optional< T > if underlying type T is non-default constructible, non-copyable/moveable, but one's instance still can exist?
Is it forbidden for boost::o...
Bethezel asked 15/5, 2013 at 4:8
2
Solved
I want to make an abstract base class non-copyable and force any classes that derive from it to be non-copyable. The below code uses Boost's noncopyable as defined in noncopyable.hpp yet still allo...
Laic asked 18/3, 2013 at 11:34
4
Solved
For example:
class Foo : boost::noncopyable
{
// ...
};
class Bar : public Foo
{
// ...
};
Is Bar non-copyable?
Astraea asked 28/7, 2011 at 18:29
1
Solved
Possible Duplicate:
Can I list-initialize a vector of move-only type?
I use gcc 4.6.1 to compile this code
int main()
{
std::vector<std::unique_ptr<int>> vec({
std::uni...
Mitchiner asked 24/7, 2011 at 0:33
4
Solved
I find that making a class non-copyable helps me a lot with my code quality. Initially I did this with boost::noncopyable, but I found the VC++ compiler errors to be not as helpful as with private ...
Stucco asked 7/7, 2011 at 18:53
2
Solved
Is this class design the standard C++0x way to prevent copy and assign, to protect client code against accidental double-deletion of data?
struct DataHolder {
int *data; // dangerous resource
Da...
Flexuosity asked 16/4, 2011 at 15:25
2
Just a question. Looking at C++ Boost libraries (in particular boost::thread class) I ended up thinking: "how is it possible to create a class defining objects that cannot be copied but that can be...
Augie asked 23/11, 2010 at 19:50
4
Solved
Assuming I have:
class A which is non-copyable
class B which has as a member, const A& a (and takes an A in its constructer and sets it in its initialization list)
a function A GenerateA();
...
Carolynecarolynn asked 10/11, 2010 at 4:41
5
Solved
I have a question about the following code:
class MyClass : private boost::noncopyable
{
public:
MyClass() {}
virtual ~MyClass() {}
}
class OtherClass : private boost::noncopyable
{
private:...
Kimberli asked 12/1, 2010 at 20:45
1 Next >
© 2022 - 2025 — McMap. All rights reserved.