cpp home

https://en.cppreference.com/w/

 

 

 

The zero-overhead principle is a C++ design principle that states:

  1. You don't pay for what you don't use.
  2. What you do use is just as efficient as what you could reasonably write by hand.

In general, this means that no feature should be added to C++ that would impose any overhead, whether in time or space, greater than a programmer would introduce without using the feature.

The only two features in the language that do not follow the zero-overhead principle are runtime type identification and exceptions, and are why most compilers include a switch to turn them off.

 

 

#include <string>
using namespace std;

int  f(unsigned long long d){
    return 1;
}
//int  f( long long d){
//    return 1;
//}

int fs(const string& p, char *o){
    return p == o;
}

int cmain(int argc, char *argv[])
{
    char e[]="efawse";
    auto z=fs("efawse", e);
    int k=9;
    k=f(k);

    return 0;
}

#include "tuple.h"

struct E{
    struct D{
        void f(E *e){
            return z(e);
        }
        void z(E *e){
            e->f();
        }
    };

private:
    void f(){

    }
};

#include <iostream>
using std::cout;

typedef void (*TestFuncType)(void);
#include <string>
#include <list>

typedef std::string String;

int smain(int argc, char *argv[])
{
    E e;
    E::D d;
    d.f(&e);
    int k=9;
    Tuple<int, char> m (k, '7');
    return 0;
}

struct A{
    A(){

    }
//    A(const A&){
//cout<<"A&\n";
//    }
//    A(A&&){
//cout<<"A&&\n";
//    }
     const char * p;
};

struct B{
    B(){

    }
//    B(const B&){
//cout<<"B&\n";
//    }
//    B(B&&){
//        cout<<"B&&\n";
//    }
};

struct C{
    A a;
    B b;
};

int main(int argc, char *argv[])
{
//    A a ;
//    a.p = 98;
//    A b = a;
    C c;
    c.a.p = "efs";
    cout << "see\n";
    C e((C&&)c);
    cout << "end\n";
    return 0;
}

原文链接: https://www.cnblogs.com/Janly/p/13213301.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    cpp home

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/360766

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年3月2日 下午1:29
下一篇 2023年3月2日 下午1:29

相关推荐