A Journey Into Non-Virtual Polymorphism
Rud Merriam | A Journey into Non-Virtual Polymorphism 2 Who Doesn’t Recognize This?? 1990 Borland Turbo C++Cppcon 2023 | Rud Merriam | A Journey into Non-Virtual Polymorphism 3 Background ● Experience – Medium.com (https://medium.com/@rudmerriam)Cppcon 2023 | Rud Merriam | A Journey into Non-Virtual Polymorphism 4 Polymorphism ● Greek: “many forms” (Obligatory statement) ● The use of a single variableCppcon 2023 | Rud Merriam | A Journey into Non-Virtual Polymorphism 5 Polymorphic Variables ● Base class pointer to derived class – Virtual functions are not bad! ● Standard Template Library0 码力 | 43 页 | 536.84 KB | 5 月前3Optimizing Away Virtual Functions May Be Pointless
carePhoto by Tech Nick on unsplashSimple benchmark class Base { public: int concrete() const; virtual int virt() const; }; void benchmark(Base *b, size_t num_iterations) { auto start = Clock::now(); virt_duration = end-start;There are interesting technical details and surprising conclusions that virtual functions can be actually faster. Since CPU architectures are mentioned, I'd expect to see deep nt-vs-inheritance-vs-other- ways-performanceDoes it even matter?Conclusions ● The notion that “virtual functions are slower” is flat out wrong. ○ Which is not to say they are faster ○ Some of the suggested0 码力 | 20 页 | 1.19 MB | 5 月前3BehaviorTree.CPP: Task Planning for Robots and Virtual Agents
name, const NodeConfig& config) : SyncActionNode(name, config) {} // You must override this virtual function NodeStatus tick() override { std::cout << "Type: [ApproachEnemy]. Instance:" <<0 码力 | 59 页 | 7.97 MB | 5 月前3百度超级链 XuperChain stable 中文文档
Transactions of the block, only txid stored on kv, the detail information 33 // stored in another table 34 // 交易内容 35 repeated Transaction transactions = 11; 36 // The transaction count of the 转换后的c代码最终会编译成一个动态链接库来给XVM运行时来使用,在每个 生成的动态链接库里面都有如下初始化函数。 这个初始化函数会自动对wasm 里面的各个模块进行初始化,包括全局变量、内存、table、外部符号解析等。 1 typedef struct { 2 void* user_ctx; 3 wasm_rt_gas_t gas; 4 u32 g0; 5 t)); 11 (h->user_ctx) = user_ctx; 12 init_globals(h); 13 init_memory(h); 14 init_table(h); 15 return h; 16 } 3.4. 语言运行环境 3.4.1. c++运行环境 c++因为没有runtime,因此运行环境相对比较简单,只需要设置基础的堆栈分 布0 码力 | 325 页 | 26.31 MB | 1 年前3Reference guide for FCL units. Document version 3.2.2
of them are unique to Free Pascal. 88 Chapter 1 Reference for unit ’ascii85’ 1.1 Used units Table 1.1: Used units by unit ’ascii85’ Name Page Classes ?? System ?? sysutils ?? 1.2 Overview The ascThreeEncodedChars,ascFourEncodedChars, ascNoEncodedChar,ascPrefix) 89 CHAPTER 1. REFERENCE FOR UNIT ’ASCII85’ Table 1.2: Enumeration values for type TASCII85State Value Explanation ascFourEncodedChars Four encoded TASCII85RingBuffer.FillCount (95) 95 Chapter 2 Reference for unit ’AVL_Tree’ 2.1 Used units Table 2.1: Used units by unit ’AVL_Tree’ Name Page Classes ?? System ?? sysutils ?? 2.2 Overview The0 码力 | 953 页 | 2.21 MB | 1 年前3Reference guide for FCL-res units. Document version 3.2.2
In this document, data sizes are specified with pascal-style data types. They are the following: Table 1: Name Meaning longword Unsigned 32 bit integer. ptruint Unsigned integer of the size of a pointer also that pointers to strings are really pointers, and not offsets to the beginning of the string table. Resource sections Free Pascal uses two sections to store resource information: • fpc.resources in the form of nodes • The string table, which can be optional • The resource data The initial header The fpc.resources section starts with this header: Table 2: Name Offset Length Description0 码力 | 211 页 | 498.14 KB | 1 年前3C++ Exceptions for Smaller Firmware
output_pin { public: virtual ~output_pin() = default; virtual void level(bool p_high) = 0; }; 2122 class output_pin { public: virtual ~output_pin() = default; virtual void level(bool p_high) not severe ‼ severe 🚨 28class output_pin { public: virtual ~output_pin() = default; virtual status level(bool p_high) = 0; virtual resultlevel() = 0; }; 29 std::expected 30 on GCC ARM 95Things that will NOT be covered here ● Nested exceptions ● Anything other than table based exceptions 96Consider the following 97 struct error {}; void foo() { try { bar(); 0 码力 | 237 页 | 6.74 MB | 5 月前3Reference guide for Free Pascal, version 3.2.2
. . . . 80 Normal static methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Virtual methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Abstract methods . 6.2 Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.6.3 Virtual methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.6.4 Class methods saveregisters softfloat specialize static stdcall stored strict unaligned unimplemented varargs virtual winapi write Remark Predefined types such as Byte, Boolean and constants such as maxint are not0 码力 | 268 页 | 700.37 KB | 1 年前3Reference guide for RTL units. Document version 3.2.2
included in the packages, or in the FCL. 139 Chapter 1 Reference for unit ’BaseUnix’ 1.1 Used units Table 1.1: Used units by unit ’BaseUnix’ Name Page unixtype 2087 1.2 Overview The BaseUnix unit was ESysENETUNREACH = 101 System error: Network is unreachable ESysENFILE = 23 System error: File table overflow ESysENOANO = 55 System error: No anode 146 CHAPTER 1. REFERENCE FOR UNIT ’BASEUNIX’ (User-defined signal 1) SIGUSR2 = 12 Signal: USR2 (User-defined signal 2) SIGVTALRM = 26 Signal: VTALRM (Virtual alarm clock) SIGWINCH = 28 Signal: WINCH (Window/Terminal size change) SIGXCPU = 24 Signal: XCPU0 码力 | 2191 页 | 4.93 MB | 1 年前3User’s Guide for Free Pascal, Version 3.2.2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 6.10.3 The ASCII table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 6.10.4 The calculator . . . . or /lib/ld- linux.so.1, depending on which one is found first. -Fmxxx Load the unicode conversion table from file x.txt in the directory where the compiler is located. Only used when -Fc is also in effect run-time error will be generated. -CR Generate checks when calling methods to verify if the virtual method table for that object is valid. -Csxxx Set stack size to xxx. -Ct Generate stack checking code0 码力 | 217 页 | 756.57 KB | 1 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100