is exists可以传数组查询吗_C++中数组类型的操作
本文演示了一些内置函数,这些函数可用于查询和操作数组类型,甚至多维数组。 这些功能在我们需要信息或操纵以不同维度发起的数组的情况下很有用。这些函数在头文件中定义。其中一些功能包括:
1.is_array():顾名思义,此函数的唯一目的是检查变量是否为数组类型。 这里值得注意的是,根据此函数,即使std :: array也不会被视为数组。如果类型为数组,则“值”成员常量将返回true,否则返回false。
2.is_same():此函数用于检查类型关系,如果两个类型具有完全相同的特征,则返回true。如果类型相同,则“value”成员常量返回true,否则返回false。
// C++ code to demonstrate the working of // is_array() and is_same() #include #include #include #include using namespace std; int main() { // checking which is array using is_array cout << "Is Integer an array? : " << is_array::value << endl; cout << "Is Array an array? : " << is_array::value << endl; cout << "Is 2D Array an array? : " << is_array::value << endl; cout << "Is String an array? : " << is_array::value << endl; cout << "Is Character Array an array? : " << is_array::value << endl; cout << "Is Array class type an array? : " << is_array>::value << endl; cout << endl; // checking for same types using is_same() cout << "Is 2D array same as 1D array? : " << is_same::value << endl; cout << "Is Character array same as Integer array? : " << is_same::value << endl; cout << "Is 1D array same as 1D array (Different sizes) ? : " << is_same::value << endl; cout << "Is 1D array same as 1D array? (Same sizes): " << is_same::value << endl; return 0; }
输出:
Is Integer an array? : 0Is Array an array? : 1Is 2D Array an array? : 1Is String an array? : 0Is Character Array an array? : 1Is Array class type an array? : 0Is 2D array same as 1D array? : 0Is Character array same as Integer array? : 0Is 1D array same as 1D array (Different sizes) ? : 0Is 1D array same as 1D array? (Same sizes): 1
3.rank():这是一个属性查询函数,它返回数组的秩。Rank表示数组的维数。值成员常量返回对象的秩。
// C++ code to demonstrate the working of // rank() #include // for array query functions #include using namespace std; int main() { // checking rank of different types cout << "The rank of integer is : " << rank::value << endl; cout << "The rank of 1D integer array is : " << rank::value << endl; cout << "The rank of 2D integer array is : " << rank::value << endl; cout << "The rank of 3D integer array is : " << rank::value << endl; cout << "The rank of 1D character array is : " << rank::value << endl; cout << endl; }
输出:
he rank of integer is : 0The rank of 1D integer array is : 1The rank of 2D integer array is : 2The rank of 3D integer array is : 3The rank of 1D character array is : 1
4.extent() :两个范围和删除范围都是复合类型的改变,可以应用于C++中的数组。此函数返回数组的特定维度的大小。此函数接受两个参数,即数组类型和必须找到其大小的维。 这也具有用于打印值的成员常数值。
5.remove_extent():此函数从声明的矩阵/数组的左侧开始删除第一维。
6.remove_all_extents():此函数删除矩阵/数组的所有维并将其转换为基本数据类型。
// C++ code to demonstrate the working of // extent(), remove_extent(), remove_all_extents() #include // for array query functions #include using namespace std; int main() { // Checking extent of different types (using extent) cout << "The extent of 1st dimension of 3D integer array is : " ; cout << extent::value << endl; cout << "The extent of 2nd dimension of 3D integer array is : " ; cout << extent::value << endl; cout << "The extent of 3rd dimension of 3D integer array is : " ; cout << extent::value << endl; cout << "The extent of 4th dimension of 3D integer array is : " ; cout << extent::value << endl; cout << endl; // Removing extent of types cout << "The rank after removing 1 extent is : " ; cout << rank::type>::value << endl; // 1st dimension from left is deleted cout << "The extent of 1st after removing 1 extent is : " ; cout << extent::type>::value << endl; cout << endl; // Removing all extents of types cout << "The rank after removing all extents is : " ; cout << rank::type>::value << endl; // All extents are deleted cout << "The extent of 1st after removing all extents is : " ; cout << extent::type>::value << endl; cout << endl; }
输出:
The extent of 1st dimension of 3D integer array is : 20The extent of 2nd dimension of 3D integer array is : 10The extent of 3rd dimension of 3D integer array is : 40The extent of 4th dimension of 3D integer array is : 0The rank after removing 1 extent is : 2The extent of 1st after removing 1 extent is : 10The rank after removing all extents is : 0The extent of 1st after removing all extents is : 0
is exists可以传数组查询吗_C++中数组类型的操作相关推荐
- jfinal ajax传值,JFINAL+Ajax传参 array 数组方法 获取request中数组操作
前台代码js var _list =[]; for (var i = 0; i < array.length; i++) { _list[i] = array[i]; } $.ajax({ ty ...
- c# list 容量_C#中数组、ArrayList和List三者的区别 转
在C#中数组,ArrayList,List都能够存储一组对象,那么这三者到底有什么样的区别呢. 数组 数组在C#中最早出现的.在内存中是连续存储的,所以它的索引速度非常快,而且赋值与修改元素也很简单. ...
- C# 数组增加元素_C#的集合类型及使用技巧
在日常开发过程中,我们不能避免的要对批量数据处理,这时候就要用到集合.集合总体上分为线性集合和非线性集合.线性集合是指元素具有唯一的前驱和后驱的数据结构类型:非线性集合是指有多个前驱和后驱的数据结构类 ...
- c#数组赋初值_c语言数组的定义及赋值
一维数组的定义方式如下:类型说明符 数组名[常量表达式]; 例如:int a[5]; 它表示定义了一个整型数组,数组名为 a,定义的数组称为数组 a. 此时数组 a 中有 5 个元素,每个元素都是 i ...
- 对象数组的初始化_JAVA中数组是什么?
Java中数组是相同类型数据的有序集合.数组描述的是相同类型的若干个数据,按照一定的先后次序排列组合而成.其中,每一个数据称作一个元素,每个元素可以通过一个索引(下标)来访问它们.数组的三个基本特点: ...
- 数组反向遍历ios_iOS中数组遍历的方法及比较
数组遍历是编码中很常见的一种需求,我们来扒一拔iOS里面都有什么样的方法来实现,有什么特点. 因为ios是兼容C语言的,所以c语言里面的最最常见的for循环遍历是没有问题的. 本文中用的数组是获取的系 ...
- java数组下标0_Java语言中数组元素下标从0开始。
[单选题]规范规定,硅酸盐水泥的初凝时间不小于( ). [判断题]打开/关闭"对象追踪"的功能键是F11. [判断题]break语句的作用是结束当前的循环体. [单选题]项目标识代 ...
- php中如何比较数组和字符串,PHP中数组和字符串的相互转换-PHP数组和字符串互相转换方法-吾爱编程网...
网站开发过程中有时候会有一些字符串和数组互转,接下来吾爱编程为大家介绍一下字符串和数组互转的方法,有需要的小伙伴可以参考一下: 1.将字符串转换为数组:/** * 将字符串转换为数组 * @param ...
- java 数组 length 减少_java中数组有没有length()方法?string没有lenght()方法?
java中数组有没有length()方法,求数组的长度可以使用数组的length属性. int length=arr.length;//求数组的长度 ------------------------- ...
- java 数组 初始化 个数_Java中数组的初始化
一.什么是初始化 在Java程序开发中,使用数组之前都会对其进行初始化,这是因为数组是引用类型,声明数组只是声明一个引用类型的变量,并不是数组对象本身,只要让数组变量指向有效的数组对象,程序中就可使用 ...
最新文章
- opengl载入多个3ds模型失败记
- antd如何获取表单的值_antd 父组件获取子组件中form表单的值
- 对渠道流量异常情况的分析
- P4389 付公主的背包(生成函数,多项式exp)
- Tomcat中设置数据源和连接池
- python mysql numpy_Python 之Numpy应用
- C++ Const深入解析
- 两个变量相乘_自动控制原理-信号流图与系统状态变量传递函数之间联系如此紧密...
- sklearn--各分类算法简单应用
- async/await 异步编程(转载)
- gradle配置阿里Maven仓库
- 深入安卓Package Manager|Package Installer
- SaaSpace:最好的免费网络安全工具
- 3dmax如何删除多余的时间帧
- python中rect用法_pyGame中rect对象的方法解释,pygame,Rect,详解
- 中小型企业如何做好网络品牌推广?
- Ros:people包下子包leg_detector及其相关包笔记
- 【bzoj1455】罗马游戏 可并堆
- 美通企业日报 | 海信发布中国首款社交电视;阿里与VEX将成立高校机器人联盟...
- sublime常用快键键
热门文章
- 【CSS系列】获取实时数据做进度
- Deep Learning 论文笔记 (3): Deep Learning Face Attributes in the Wild
- yii模版中的判断方法
- 微信小程序 post git 的请求坑
- Google 宣布正式开源 Jib ,帮助 Java 应用快速容器化
- 撤销工作表保护原密码_批量解除工作表保护,和批量执行保护一样简单
- python从列表某位置开始读取_python如何读取列表中元素的位置?
- gogs 创建新的仓库
- 悄悄安装vcredist_x64.exe,不弹出对话框
- 同样是百度输入法,定制远没有原版好用