C++ 知道禁用 copy-ctor/assign operator 是 C++ 程序员的试金石
来源:互联网 发布:照相机卡数据视频恢复 编辑:程序博客网 时间:2024/06/10 14:49
陈硕CSDN博客 :知道禁用 copy-ctor/assign operator 是 C++ 程序员的试金石
vgxpm的专栏:C++之实现禁用 copy-ctor/assign operator : 对其进行了解释,详细阅读
陈硕github/muduo : Singleton.h 的实现中对其对copy-ctor/assign operator进行禁用,利用继承noncopyable,代码:
class Singleton : boost::noncopyable
boost/core/noncopyable.hpp
// Boost noncopyable.hpp header file --------------------------------------//// (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost// Software License, Version 1.0. (See accompanying file// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)// See http://www.boost.org/libs/utility for documentation.#ifndef BOOST_CORE_NONCOPYABLE_HPP#define BOOST_CORE_NONCOPYABLE_HPP#include <boost/config.hpp>namespace boost {// Private copy constructor and copy assignment ensure classes derived from// class noncopyable cannot be copied.// Contributed by Dave Abrahamsnamespace noncopyable_ // protection from unintended ADL{ class noncopyable { protected:#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS) BOOST_CONSTEXPR noncopyable() = default; ~noncopyable() = default;#else noncopyable() {} ~noncopyable() {}#endif#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) noncopyable( const noncopyable& ) = delete; noncopyable& operator=( const noncopyable& ) = delete;#else private: // emphasize the following members are private noncopyable( const noncopyable& ); noncopyable& operator=( const noncopyable& );#endif };}typedef noncopyable_::noncopyable noncopyable;} // namespace boost#endif // BOOST_CORE_NONCOPYABLE_HPP
0 0
- C++ 知道禁用 copy-ctor/assign operator 是 C++ 程序员的试金石
- C++之实现禁用 copy-ctor/assign operator
- Object c assign/retain/copy
- 禁用 copy & assign
- 时间是最好的试金石
- [C++]copy constructor and copy assignment operator
- Objective-c中属性的assign, retain, copy的用法
- object-c语言的nonatomic,assign,copy,retain的区别
- OBJ-C中的retain,copy,assign的区别
- objective-c中nonatomic,assign,copy,retain的区别
- assign,copy,retain -Object-C中纠结的三个属性(assign)
- objective-c 中retain,assign,copy
- object-c:property,assign,copy,retain,release
- objective-c -- nonatomic,assign,copy,retain 理解
- object-c中的assign retain copy
- Objective-C - retain release autorelease assign copy
- [Objective-C] assign/retain/copy 详解
- Objective-C assign、retain、copy区别
- BZOJ 3144: [Hnoi2013]切糕
- 【ShawnZhang】带你看数据结构——第五课:堆栈
- ffmpeg 水印问题
- 算法-分治法实例:循环赛日程安排问题
- 《王保明老师----Linux开发学习笔记》------讲03:进程
- C++ 知道禁用 copy-ctor/assign operator 是 C++ 程序员的试金石
- ZOJ 3911 线段树 区间更新查找,求素数个数
- 设计模式之-观察者模式
- 图像卷积与滤波的一些知识点
- sql 取表的前10条记录,任意中间几行的记录
- 设计模式之中介者模式
- NYOJ 20 吝啬的国度 (DFS & vector)
- 【SQlite关系型数据库】SQLiteOpenHelper
- 计算机视觉、机器学习相关领域论文和源代码大集合--持续更新……