searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

禁用拷贝函数基类和单例基类写法

2024-10-17 09:34:20
1
0
一种禁用拷贝函数基类和单例基类写法
#pragma once
 
namespace detail {
 
class DisallowCopy {
public:
DisallowCopy() = default;
~DisallowCopy() = default;
private:
DisallowCopy(const DisallowCopy&) = delete;
DisallowCopy(DisallowCopy&&) = delete;
void operator = (const DisallowCopy&) = delete;
void operator = (DisallowCopy&&) = delete;
};
 
template <class T>
class SimpleSingleton {
friend T;
public:
static T& Instance() {
static T inst;
return inst;
}
private:
SimpleSingleton() = default;
};
 
}
0条评论
0 / 1000
邱****谋
7文章数
0粉丝数
邱****谋
7 文章 | 0 粉丝
原创

禁用拷贝函数基类和单例基类写法

2024-10-17 09:34:20
1
0
一种禁用拷贝函数基类和单例基类写法
#pragma once
 
namespace detail {
 
class DisallowCopy {
public:
DisallowCopy() = default;
~DisallowCopy() = default;
private:
DisallowCopy(const DisallowCopy&) = delete;
DisallowCopy(DisallowCopy&&) = delete;
void operator = (const DisallowCopy&) = delete;
void operator = (DisallowCopy&&) = delete;
};
 
template <class T>
class SimpleSingleton {
friend T;
public:
static T& Instance() {
static T inst;
return inst;
}
private:
SimpleSingleton() = default;
};
 
}
文章来自个人专栏
windows编程
7 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0