Key_handle的学习
代码
一切尽在不言中
#pragma once#include "common/common.h"
#include "sdf/sdf.h"#include <memory>namespace sdf {namespace algorithm {class KeyHandle {public:using erased_internal_data_t = char; //使用erased_internal_data_t等效于char,此处用法相当于typedefKeyHandle() = default;//构造函数,使用默认参数virtual ~KeyHandle() = default;//析构函数,使用默认参数KeyHandle(const KeyHandle &) = delete;//赋值构造函数//参考链接 https://blog.csdn.net/TanJiaLiang_/article/details/86691437?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.compare&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.compareKeyHandle &operator=(const KeyHandle &) = delete;//复制赋值//https://zh.cppreference.com/w/cpp/language/operators/*** @brief construct an empty key handle //摘要** @tparam T internal type //参数* @return unique_ptr to KeyHandle which contains empty internal data*/template <typename T> static std::unique_ptr<KeyHandle> make() {//template <typename T> 模板类//static std::unique_ptr https://mp.csdn.net/console/editor/html/109365196auto key_handle = std::make_unique<KeyHandle>();//std::make_unique https://zh.cppreference.com/w/cpp/memory/unique_ptr/make_unique// erase internal typekey_handle->data.reset(reinterpret_cast<char *>(new T()),internal_data_deleter<T>);//reinterpret_cast https://blog.csdn.net/iflyme/article/details/83378697//data.reset data属于std::shared_ptr<erased_internal_data_t>类型 https://zh.cppreference.com/w/cpp/memory/shared_ptr/resetkey_handle->data_length = sizeof(T);return key_handle;}/*** @brief cast to internal type for accessing raw key data** @tparam T internal type* @return pointer to internal data*/template <typename T> T *cast() { return reinterpret_cast<T *>(data.get()); }/*** @brief cast to internal type for accessing raw key data** @tparam T internal type* @return const pointer to internal data*/template <typename T> const T *cast() const {return reinterpret_cast<const T *>(data.get());}/*** @brief convert to native handle representation for public c style apis** @return sdf_handle_t type pointer to this*/sdf_handle_t native_handle() const {return reinterpret_cast<sdf_handle_t>(const_cast<KeyHandle *>(this));}/*** @brief convert to native 64-bits representation for grpc conversions** @return uint64_t type number equals to address of this*/uint64_t native_handle_64ull() const {return reinterpret_cast<uint64_t>(this);}/*** @brief access key handle via native handle** @param native_handle public c style handle* @return pointer to KeyHandle*/static KeyHandle *from_native_handle(sdf_handle_t native_handle) {return reinterpret_cast<KeyHandle *>(native_handle);}/*** @brief access key handle via native 64-bits representation** @param native_handle_64ull native 64-bits representation* @return pointer to KeyHandle*/static KeyHandle *from_native_handle_64ull(uint64_t native_handle_64ull) {return reinterpret_cast<KeyHandle *>(native_handle_64ull);}private:template <typename T>static void internal_data_deleter(const erased_internal_data_t *ptr) {delete reinterpret_cast<const T *>(ptr);}protected:std::shared_ptr<erased_internal_data_t> data; ///< internal datasize_t data_length = 0; ///< length of internal data};} // namespace algorithm
} // namespace sdf
Key_handle的学习相关推荐
- java入门 慕路径,Java入门基础知识总结学习教程大全【必看经典】
类型的表达式,是循环条件,表达式3是党执行了一遍循环之后,修改控制循环的变量值. ??? for语句的执行过程是这样的:首先计算表达式1,完成必要的初始化工作:然后判断表达式2的值,如果表达式的值为t ...
- Java EE学习心得
–Java EE学习心得 1. 称为编程专家的秘诀是: 思考-----编程--------思考------编程--.. 编程不能一步到位,不能一上来就编,必须先思考如何写,怎样写?然后再编程 ...
- FastAI 2019课程学习笔记 lesson 2:自行获取数据并创建分类器
文章目录 数据获取 google_images_download 的安装和使用 挂载google 个人硬盘到Google colab中 删除不能打开文件 创建ImageDataBunch 训练模型 解 ...
- FastAI 课程学习笔记 lesson 1:宠物图片分类
文章目录 代码解析 神奇的"%" 导入fastAI 库 下载解压数据集 untar_data 获取帮助文档 help() ? ?? doc 设置路径 get_image_files ...
- 深度学习学习指南-工具篇
colab Colab是由Google提供的云计算服务,通过它可以让开发者很方便的使用google的免费资源(CPU.GPU.TPU)来训练自己的模型. 学习经验总结 如何使用命令行? 通过!+cmd ...
- Redis学习之路(一)--下载安装redis
redis学习之路--下载安装redis windows安装redis 1.下载redis 2.安装 3.查看是否安装成功 windows安装redis 1.下载redis 网址:https://gi ...
- python内置库之学习configparser库(一)
python内置库之学习configparser库(一) 1.引言 ini文件简介 [节] 键=值 注:节不能重复出现 2.自己封装了一个增删改查的类,可以参考一下 import configpars ...
- 前端Vue学习之路(二)-Vue-router路由
Vue学习之路 (二) Vue-router(基础版) 一.增加静态路由 二.动态路由+路由嵌套+404页面 三. 编程式导航 四.命名路由 五.命名视图 六.重定向和起别名 1.重定向 2.起别名 ...
- 前端Vue学习之路(一)-初识Vue
Vue学习之路 (一) 1.引言 2.更换npm国内镜像源 3.用npm下载Vue 4.Vue全家桶 5.使用命令创建项目 5.推荐插件 6.推荐网站 7.学习扩展 1.引言 先安装node.js环境 ...
最新文章
- Nexus3 使用root无法启动解决
- android loadlibrary 更改libPath 路径,指定路径加载.so
- DOM方式动态加载数据
- js手机端时间区间_js 时间区间
- BZOJ2209: [Jsoi2011]括号序列
- ACCESS在哪输入SQL语句
- 【今晚7点半】:超低延迟下的实时合唱体验升级
- Linux Kernel ‘mp_get_count()’函数本地信息泄露漏洞
- python 给类添加属性_python – 如何动态添加属性到类中?
- CentOS7.2安装jdk7u80
- 二叉树查找结点及父结点_【剑指offer】57 二叉树的下一个结点
- “互联网+”大学生创新创业大赛项目策划书
- 自己写的一个GPS卫星地图
- 企业产品互联网推广的有效方法
- SpringBoot+Vue实现前后端分离的财务管理系统
- A - Faulty Odometer
- 自定义 iPhone 铃声
- 笔记|matplotlib 技巧|使用 gricspec 实现的不同大小子图
- 两次维权ZB系交易所,我和ZB的魔幻往事
- 【Maven】简介信息
热门文章
- vb如何定义微软服务器stul,VBScrip微软官方教程.doc
- 软件oem要注意什么_做化妆品oem,选择化妆品包材要注意什么问题
- 利用python读取栅格数据
- 【转】VScode快捷键(超无敌详细版)
- 了解Entity Framework中事务处理
- VBA类之一(初识类)
- linux磁盘永久挂载教程,linux 永久磁盘挂载
- Hbase搭建-基于hadoop3--并且解决了hbase error: KeeperErrorCode = NoNode for /hbase/master错误
- REVERSE-PRACTICE-BUUCTF-6
- 【CodeForces - 1A】Theatre Square(水题,几何)(CODEFORCES,梦的开始)