zoukankan      html  css  js  c++  java
  • 如何比较两个变量的类型是否相同

            template <typename T1, typename T2>
            inline const bool compare_type(T1, T2)
            {
                return false;
            }

            template <>
            inline const bool compare_type(intint)
            {
                return true;
            }

            template <>
            inline const bool compare_type(floatfloat)
            {
                return true;
            }

            template <>
            inline const bool compare_type(doubledouble)
            {
                return true;
            }

            template <>
            inline const bool compare_type(charchar)
            {
                return true;
            }

            template <>
            inline const bool compare_type(wchar_t, wchar_t)
            {
                return true;
            }

            template <typename T1, typename T2>
            inline const bool compare_type(T1*, T2*)
            {
                return compare_type(T1(), T2());
            }

            template <typename T1, typename T2>
            inline const bool compare_type(const T1*, const T2*)
            {
                return compare_type(T1(), T2());
            }

            template <typename T1, typename T2>
            inline const bool compare_type(const T1*, T2*)
            {
                return false;
            }

            template <typename T1, typename T2>
            inline const bool compare_type(T1*, const T2*)
            {
                return false;
            }
    通过特例化,我们可以很轻松的查看两个变量的类型是否相同。
  • 相关阅读:
    5.Hibernate实现全套增删改查和ajax异步分页
    3、Hibernate三态间的转换
    0. Java开发中的23种设计模式详解(转)
    4、Hibenrate中HQL的10中查询方式
    1.Hibernate框架核心组件 (转自冯岩)
    VB 进制转换大全
    详解 CSS 属性
    HTML5开发规范
    在 Windows 7 環境安裝 Python 2.6.6
    IBM开发者 JSON 教程
  • 原文地址:https://www.cnblogs.com/lwch/p/2656712.html
Copyright © 2011-2022 走看看