首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏C++核心准则原文翻译

    C++核心准则C.89:保证哈希不会抛出异常

    It's a standard-library requirement. 哈希容器的用户间接地使用哈希功能,不希望简单的操作发生异常。这是标准库的要求。 My_type{ "asdfg" }] << '\n'; } If you have to define a hash specialization, try simply to let it combine standard-library

    45830发布于 2020-03-25
  • 来自专栏C++核心准则原文翻译

    C++核心准则C.61:拷贝操作应该具有拷贝的效果

    copy x and y can be independent objects (value semantics, the way non-pointer built-in types and the standard-library Value semantics is the simplest to reason about and what the standard-library facilities expect.

    54710发布于 2020-03-25
  • 来自专栏C++核心准则原文翻译

    C++核心准则ES.107:不要使用无符号数下标,使用gsl::index更好​

    The standard-library containers use unsigned subscripts. Thus, no perfect and fully compatible solution is possible (unless and until the standard-library containers use range-for 使用范围for use iterators/pointers 使用指针和迭代器 Enforcement(实施建议) Very tricky as long as the standard-library

    1.2K10发布于 2020-06-24
  • 来自专栏C++核心准则原文翻译

    C++核心准则CP.4:按照任务思考问题,而不是线程

    publisher.join(); } Note(注意) With the exception of async(), the standard-library facilities are low-level argument for using higher level, more applications-oriented libraries (if possibly, built on top of standard-library

    43110发布于 2020-07-03
  • 来自专栏C++核心准则原文翻译

    C++核心准则E.12: 当不可能或不愿意通过抛出异常退出函数时使用noexcept

    Note(注意) Many standard-library functions are noexcept including all the standard-library functions "inherited

    85420发布于 2020-08-04
  • 来自专栏C++核心准则原文翻译

    C++核心准则E.14:使用根据目的设计的用户定制类型异常(非内置类型)

    catch(int i) { // i == 7 means "input buffer too small" // ... } } Note(注意) The standard-library Maybe warn about throw and catch using a standard-library exception type.

    51410发布于 2020-08-04
  • 来自专栏C++核心准则原文翻译

    C++核心准则C.65:让移动操作对自赋值安全

    Note(注意) The ISO standard guarantees only a "valid but unspecified" state for the standard-library containers (Not enforceable) Look at the use of standard-library container types (incl. string) and consider them

    46120发布于 2020-03-25
  • 来自专栏C++核心准则原文翻译

    C++核心准则SL.con.3:避免越界错误

    Note(注意) The standard-library functions that apply to ranges of elements all have (or could have) bounds-safe v.at(0) = at(a, i); // OK (alternative 2) } Enforcement(实施建议) Issue a diagnostic for any call to a standard-library

    86851发布于 2020-10-30
  • 来自专栏C++核心准则原文翻译

    C++核心准则编译边学-F.47 赋值运算符应该返回T&

    This ensures consistency with standard-library types and follows the principle of "do as the ints do.

    44610发布于 2020-03-25
  • 来自专栏C++核心准则原文翻译

    C++核心准则Per.5,6 关于性能的误解

    Note(注意) A few simple microbenchmarks using Unix time or the standard-library <chrono> can help dispel

    42720发布于 2020-06-24
  • 来自专栏C++核心准则原文翻译

    C++核心准则C.84:swap函数不应该失败

    The standard-library containers and algorithms will not work correctly if a swap of an element type fails

    54220发布于 2020-03-25
  • 来自专栏C++核心准则原文翻译

    C++核心准则C.66:保证移动操作不会抛出异常

    A non-throwing move will be used more efficiently by standard-library and language facilities.

    72310发布于 2020-03-25
  • 来自专栏C++核心准则原文翻译

    C++核心准则T.13:对于简单的,单类型参数概念,使用缩略记法更好

    A draft of a set of standard-library concepts can be found in another ISO TS: ranges Concepts are supported

    62010发布于 2020-08-27
  • 来自专栏C++核心准则原文翻译

    C++核心准则​讨论:持有没有被句柄管理的资源时切勿抛出异常

    For starters, we know about the standard-library containers, string, and smart pointers.

    93110发布于 2020-12-31
  • 来自专栏C++核心准则原文翻译

    C++核心准则T.10:为所有的模板参数定义概念

    A draft of a set of standard-library concepts can be found in another ISO TS: ranges Concepts are supported

    74910发布于 2020-08-27
  • 来自专栏C++核心准则原文翻译

    C++核心准则​Pro.bounds:边界安全群组

    Bounds.4: Don't use standard-library functions and types that are not bounds-checked: Use the standard

    81130发布于 2020-11-10
  • 来自专栏C++核心准则原文翻译

    C++核心准则T.5:结合使用泛型和面向对象技术应该增强它们的效果而不是成本

    Avoid this, even though the standard-library facets made this mistake.

    90520发布于 2020-08-27
  • 来自专栏C++核心准则原文翻译

    C++核心准则C.62:保证拷贝赋值对自我赋值安全

    (通常会包含泄露) Example(示例) The standard-library containers handle self-assignment elegantly and efficiently

    51020发布于 2020-03-25
  • 来自专栏C++核心准则原文翻译

    C++核心准则E.16:析构函数,内存释放和swap操作永远不能失败

    If they do, basic standard-library invariants are broken. 标准库假设析构函数,内存释放函数(例如delete运算符),swap都不会抛出异常。

    88130发布于 2020-08-04
  • 来自专栏C++核心准则原文翻译

    C++核心准则T.47:避免使用通用名称的高度不受限模板

    Realistic types, such as the standard-library iterators can be made to exhibit similar anti-social tendencies

    60430发布于 2020-09-10
领券