Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ 11 noncopyable class

Tags:

c++

c++11

Is there any class similar to http://www.boost.org/doc/libs/1_53_0/boost/noncopyable.hpp introduced by C++ 11? I can't use = delete feature as my compiler doesn't support it. I would prefer to use standard library features if possible instead of boost or implementing my own.

like image 380
Mircea Ispas Avatar asked Apr 08 '13 13:04

Mircea Ispas


People also ask

What is a Noncopyable class?

A class called non-copyable is defined which has a private copy constructor and copy assignment operator.

What is boost Noncopyable?

Boost::noncopyable prevents the classes methods from accidentally using the private copy constructor.

How do you make a class Uncopyable?

One can make a class uncopyable, i.e., move-only, by using deleted definitions of the copy constructor and copy assignment operator, and then providing defaulted definitions of the move constructor and move assignment operator. A deleted function is implicitly an inline function ([dcl. inline]).


1 Answers

No, there is no similar standard class. C++11 introduced = delete for this purpose, so additionally introducing a class would have been needlessly redundant and useless.

like image 151
Mankarse Avatar answered Sep 28 '22 18:09

Mankarse