如何在国外网站进行登录、退出并管理个人信息?

摘要:国外推广网站有哪些,网站登录怎么退出,网站鼠标经过图片代码,wordpress支持手机适应用const修饰变量或方法,从而告诉编译器这些都是不可变的,有助于编译器优化代码&
国外推广网站有哪些,网站登录怎么退出,网站鼠标经过图片代码,wordpress支持手机适应用const修饰变量或方法#xff0c;从而告诉编译器这些都是不可变的#xff0c;有助于编译器优化代码#xff0c;并帮助开发人员了解函数是否有副作用。此外#xff0c;使用const 可以防止编译器复制不必要的数据。John Carmack对const的评论[2]值得一读。 // Bad Ide…用const修饰变量或方法从而告诉编译器这些都是不可变的有助于编译器优化代码并帮助开发人员了解函数是否有副作用。此外使用const 可以防止编译器复制不必要的数据。John Carmack对const的评论[2]值得一读。 // Bad Idea class MyClass { public:void do_something(int i);void do_something(std::string str); };// Good Idea class MyClass { public:void do_something(const int i);void do_something(const std::string str); };仔细考虑返回类型 Getters(成员变量读取API) 正常情况下通过返回值读取成员变量时使用或const 返回值可以显著提高性能 按值返回更有利于线程安全如果返回的值就是为了复制使用就不会有性能损耗 如果API返回值使用协变类型(covariant return types)必须返回或* 临时值和局部值 始终按值返回 不要用const引用传递和返回简单类型 // Very Bad Idea class MyClass { public:explicit MyClass(const int t_int_value): m_int_value(t_int_value){}const int get_int_value() const{return m_int_value;}private:int m_int_value; }相反通过值传递和返回简单类型。如果不打算更改传递的值请将它们声明为const但不要声明为const引用: // Good Idea class MyClass { public:explicit MyClass(const int t_int_value): m_int_value(t_int_value){}int get_int_value() const{return m_int_value;}private:int m_int_value; }为什么要这样因为通过引用传递和返回会导致指针操作而值传递在处理器寄存器中处理速度更快。 避免访问裸内存 C中很难在没有内存错误和泄漏风险[3]的情况下正确处理裸内存的访问、分配和回收C11提供了避免这些问题的工具。 // Bad Idea MyClass *myobj  new MyClass;// ... delete myobj;// Good Idea auto myobj  std::make_uniqueMyClass(constructor_param1, constructor_param2); // C14 auto myobj  std::unique_ptrMyClass(new MyClass(constructor_param1, constructor_param2)); // C11 auto mybuffer  std::make_uniquechar[](length); // C14 auto mybuffer  std::unique_ptrchar[](new char[length]); // C11// or for reference counted objects auto myobj  std::make_sharedMyClass(); // ... // myobj is automatically freed for you whenever it is no longer used.用std::array或std::vector代替C风格的数组 这两种方法都保证了对象的连续内存布局并且可以(而且应该)完全取代C风格数组另外这也是不使用裸指针的诸多原因之一。 另外避免使用std::shared_ptr保存数组[4]。 使用异常 返回值(例如boost::optional)可以被忽略如果不检查可能会导致崩溃或内存错误而异常不能被忽略。另一方面异常可以被捕获和处理。可能异常会一直上升到应用程序的最高层级被捕获、记录到日志中并触发应用自动重启。
阅读全文