LITERALS SAFELY for Types that Behave as though Built-in - Pablo Halpern - CppCon 2021
Safely Until They Die – Alisdair Meredith & Nina Ranns, Thursday 10:30am ■ Embracing `noexcept` Operators and Specifiers Safely – John Lakos, Thursday 3:15pm 10/26/21 Pablo Halpern, 2021 (CC BY 4.0) aren't UDLs just syntactic sugar? ■ You betcha! ■ So is operator overloading. ■ So are infix operators in general! – a+b is just syntactic sugar for plus(a, b) ■ Syntactic sugar is about readability; 17Namespaces for literals ■ UDL operators are looked up using ordinary name lookup, no namespace qualifiers allowed. ■ To avoid collisions between similar UDL suffixes, UDL operators are usually put in their0 码力 | 66 页 | 1.47 MB | 5 月前3GraphBLAS: Building a C++ Matrix API for Graph Algorithms
function for each scalar type - GraphBLAS supports a wide variety of scalar types and binary operators - Combinatorial explosion 47 float* a_ptr = get_matrix(...); cblas_sgemm(..., m, n, k, 1.0f, function for each scalar type - GraphBLAS supports a wide variety of scalar types and binary operators - Combinatorial explosion[DISTRIBUTION STATEMENT A] This material has been approved for public function for each scalar type - GraphBLAS supports a wide variety of scalar types and binary operators - Combinatorial explosion[DISTRIBUTION STATEMENT A] This material has been approved for public0 码力 | 172 页 | 7.40 MB | 5 月前3Regular, Revisited
the interfaces of interest, the most pervasively and unconsciously used, are the fundamental operators common to all C++ built-in types, as extended to user-defined types, eg. copy constructors, assignment http://stepanovpapers.com/DeSt98.pdf We must investigate the relations which must hold among these operators to preserve consistency with their semantics for the built-in types and with the expectations Stepanov 1998 http://stepanovpapers.com/DeSt98.pdf We can produce an axiomatization of these operators which: yields the required consistency with built-in types matches the intuitive expectations0 码力 | 180 页 | 19.96 MB | 5 月前3Back to Basics: Classic 9STL
only valid use of the expression *p is on the left side of an assignment statement • Comparison operators are not required – no end of sequence is assumed • Output iterators model an "infinite sink" Input Iterators – Read Forward, Single-Pass • p == q does not imply ++p == ++q • The comparison operators are provided to check whether an input iterator is equal to the past-the-end iterator • All iterators capabilities and guarantees • Emulate pointers • Provide operators for iterator arithmetic, analogous to pointer arithmetic • Provide relational operators to compare positionCppCon 2021 – Back to Basics: Classic0 码力 | 75 页 | 603.36 KB | 5 月前3Expressive Compile-time Parsers
v(arr, arr + sizeof(arr) / sizeof(arr[0])); vectorv = {1,2,3,4};Operator Overloading Use operators to call custom functions for specific types. std::filesystem::path p = "C:"; return p / "files" v=Cb0j6DVmwzYLexy - DSL Create parsers by defining a struct with rule and value. Combine parsers with operators. struct json_value : /*...*/ { static constexpr auto rule = [] { auto primitive = dsl::p "int highlight_works = 42; spaces will collapse"));YACP – Yet Another Compile-Time Parser DSL and operators similar to Lexy and Boost::Spirit. Uses fixed size containers as return type. auto choice_parser 0 码力 | 134 页 | 1.73 MB | 5 月前3COMPOSABLE C++
short-circuiting is not part of composability here; it's just a semantic nicety of the operators. it's just a semantic nicety of the operators.CHAIN OF RESPONSIBILITY CHAIN OF RESPONSIBILITY A design pattern that exploits represent N (32?) bools bools,, using using bitand bitand ( (&&) and ) and bitor bitor ( (||) operators. ) operators. That's sometimes useful, but really That's sometimes useful, but really just an extension0 码力 | 124 页 | 8.28 MB | 5 月前3Back to Basics: The Abstract Machine
execution environment. (my emphasis) […] • [expr.pre](7.1) […] An expression is a sequence of operators and operands that specifies a computation. An expression can result in a value and can cause side them • Expressions with non-observable side effects may be ignored • Expression - a sequence of operators and operands that specifies a computation • Side effects - changes in the program’s execution Functions consist of statements • Statements consist of expressions • An expression is a sequence of operators and operands that specifies a computation • To perform that computation, the expression must be0 码力 | 91 页 | 538.90 KB | 5 月前3Modern C++ Tutorial: C++11/14/17/20 On the Fly
has a destructor, the properties for which it generates copy constructors and copy assignment operators are deprecated. • C language style type conversion is deprecated (ie using (convert_type)) before generating default constructors, copy constructs, assignment operators, and destructors for the object. Besides, C++ also defines operators such as new delete for all classes. This part of the function has designed the concept of copy/copy for class objects through copy constructors and assignment operators, but to implement the movement of resources, The caller must use the method of copying and then0 码力 | 92 页 | 1.79 MB | 1 年前3The Main Points of C++
suffix or exponent (e or p) .1. Just one point (dot) • In floating-point literals • Member access operators • Member of object templatestruct S { template void foo() {} in a; s.template foo (); } .1. Just one point (dot) • In floating-point literals • Member access operators • Member of object • Pointer to member of object struct S { int mi; int f(int n) const; }; << (x.*pf)(6) << endl; .1. Just one point (dot) • In floating-point literals • Member access operators • Member of object • Pointer to member of object • In module names export module Main.SubM.SubSubM; 0 码力 | 34 页 | 344.31 KB | 5 月前3Leveraging C++20/23 Features for Low Level Interactions
supports all the logic operators to manipulate bits that you have in C uint32_t value = 0; value |= 0x1; value &= ~(0x1);How to operate on the registers C++ supports all the logic operators to manipulate bits = 0; value |= 0x1; value &= ~(0x1);How to operate on the registers C++ supports all the logic operators to manipulate bits that you have in C This will all work! But… C++ can do these operations more0 码力 | 56 页 | 5.39 MB | 5 月前3
共 123 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13