zoukankan      html  css  js  c++  java
  • c++新特性-收缩转换,二进制,constexpr,以及namespace&&inline

    char(112312312);//不会检查是否超过范围,会截断

    char{12345435345};//会报异常,异常如下:

    error C2397: 从“__int64”转换到“char”需要收缩转换
     warning C4305: “初始化”: 从“__int64”到“char”截断
    warning C4309: “初始化”: 截断常量值

    c++14二进制支持(0b) 即int a=0b1001;//9,0B1101(13)

    constexpr标志返回值或其他表达式是常量,用于返回常量可以用于需要常量表达式的等数组中

    constexpr int get()

    {

      return 100;

    }

    int a[10+get()];//可以

    inline 在命名空间新特性:namespace&& inline

    #include <algorithm>
    #include <iostream>
    #include <functional>
    #include <vector>
    #include <numeric>
    #include <array>
    #include <cstring>
    #include <cstdio>
    using namespace  std;
    namespace all{
        namespace V2017
        {
            void fun(int num){ cout << "int V2017" << endl; }
    
        }
    }
    namespace all {
        //展开在all,默认调用
        inline namespace V2018
        {
            void fun(int num){ cout << "int V2018" << endl; }
            void fun(double num){ cout << "double V2018" << endl; }
    
        }
    }
    int main()
    {
        all::V2017::fun(12);//明确调用
        all::V2018::fun(16);
        all:fun(1);//默认调用
        system("pause");
    
    }
  • 相关阅读:
    控制element表格禁用选择
    深度拷贝
    VScode修复eslint报错,保存的时候自动格式修正
    关于route监听
    PAT 1030 完美数列
    PAT1029 旧键盘(C完全正确)
    PAT 1028 人口普查
    PAT 1016
    PAT:1013
    PAT :1012 数字分类
  • 原文地址:https://www.cnblogs.com/bwbfight/p/11298556.html
Copyright © 2011-2022 走看看