 Calling Functions A TutorialCalling Functions A Tutorial Klaus Iglberger, CppCon 2020 klaus.iglberger@gmx.de2 Klaus Iglberger C++ Trainer since 2016 Author of the C++ math library (Co-)Organizer of the Munich Dispatch Deleting FunctionsDisclaimer 5 This talk does … … focus on the basic mechanics of calling functions; … point out the surprising details; … give further references whenever necessary.0 码力 | 111 页 | 5.11 MB | 6 月前3 Calling Functions A TutorialCalling Functions A Tutorial Klaus Iglberger, CppCon 2020 klaus.iglberger@gmx.de2 Klaus Iglberger C++ Trainer since 2016 Author of the C++ math library (Co-)Organizer of the Munich Dispatch Deleting FunctionsDisclaimer 5 This talk does … … focus on the basic mechanics of calling functions; … point out the surprising details; … give further references whenever necessary.0 码力 | 111 页 | 5.11 MB | 6 月前3
 Template Metaprogramming: Type Traitsexisting language features • Their use is not enforced by the language • Their use is dictated by convention 11Metafunctions • A metafunction is not a function but a class/struct • Metafunctions are not existing language features • Their use is not enforced by the language • Their use is dictated by convention • C++ community has created common "standard" conventions 11Metafunctions 12Metafunctions 12Metafunctions • Technically, a class with zero+ template parameters and zero+ return types and values • Convention is that a metafunction should return one thing, like a regular function 12Metafunctions • Technically0 码力 | 403 页 | 5.30 MB | 6 月前3 Template Metaprogramming: Type Traitsexisting language features • Their use is not enforced by the language • Their use is dictated by convention 11Metafunctions • A metafunction is not a function but a class/struct • Metafunctions are not existing language features • Their use is not enforced by the language • Their use is dictated by convention • C++ community has created common "standard" conventions 11Metafunctions 12Metafunctions 12Metafunctions • Technically, a class with zero+ template parameters and zero+ return types and values • Convention is that a metafunction should return one thing, like a regular function 12Metafunctions • Technically0 码力 | 403 页 | 5.30 MB | 6 月前3
 Quantifying Accidental Complexity: An empirical look at teaching and using C++Complexity: An empirical look at teaching and using C++ Herb Sutter 9/21/2020 13 27 in X x Calling convention X if cheap to copy, else X* Caller arguments Initialized object (l- or rvalue) Callee empirical look at teaching and using C++ Herb Sutter 9/21/2020 14 29 in X x inout X x Calling convention X if cheap to copy, else X* X* Caller arguments Initialized object (l- or rvalue) empirical look at teaching and using C++ Herb Sutter 9/21/2020 15 31 in X x inout X x out X x Calling convention X if cheap to copy, else X* X* X* Caller arguments Initialized object (l- or rvalue)0 码力 | 36 页 | 2.68 MB | 6 月前3 Quantifying Accidental Complexity: An empirical look at teaching and using C++Complexity: An empirical look at teaching and using C++ Herb Sutter 9/21/2020 13 27 in X x Calling convention X if cheap to copy, else X* Caller arguments Initialized object (l- or rvalue) Callee empirical look at teaching and using C++ Herb Sutter 9/21/2020 14 29 in X x inout X x Calling convention X if cheap to copy, else X* X* Caller arguments Initialized object (l- or rvalue) empirical look at teaching and using C++ Herb Sutter 9/21/2020 15 31 in X x inout X x out X x Calling convention X if cheap to copy, else X* X* X* Caller arguments Initialized object (l- or rvalue)0 码力 | 36 页 | 2.68 MB | 6 月前3
 Is std::mdspan a Zero-overhead Abstraction? - Oleksandr Bakirov - CppConthen call the add function on assignment. 58Microsoft x64 calling convention “The x64 ABI uses a four-register fast-call calling convention by default. … Integer arguments are passed in registers RCX https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention 59Microsoft x64 calling convention “The x64 ABI uses a four-register fast-call calling convention by default. … Integer arguments are passed or 8 bytes, must be passed by reference.” https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention It looks like Microsoft just doesn’t like high-level abstractions. 60extents$ = 8 dst$ =0 码力 | 75 页 | 1.04 MB | 6 月前3 Is std::mdspan a Zero-overhead Abstraction? - Oleksandr Bakirov - CppConthen call the add function on assignment. 58Microsoft x64 calling convention “The x64 ABI uses a four-register fast-call calling convention by default. … Integer arguments are passed in registers RCX https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention 59Microsoft x64 calling convention “The x64 ABI uses a four-register fast-call calling convention by default. … Integer arguments are passed or 8 bytes, must be passed by reference.” https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention It looks like Microsoft just doesn’t like high-level abstractions. 60extents$ = 8 dst$ =0 码力 | 75 页 | 1.04 MB | 6 月前3
 Constructing Generic AlgorithmsOPTION 1 Do as the standard does. Generally the standard follows convention: Do as the standard does. Generally the standard follows convention: 66 . 1PARAMETER ORDERING: OPTION 1 PARAMETER ORDERING: OPTION OPTION 1 Do as the standard does. Generally the standard follows convention: Do as the standard does. Generally the standard follows convention: 1. ExecutionPolicy comes first (if applicable) 66 . 1PARAMETER OPTION 1 Do as the standard does. Generally the standard follows convention: Do as the standard does. Generally the standard follows convention: 1. ExecutionPolicy comes first (if applicable) 2. first, last0 码力 | 145 页 | 8.44 MB | 6 月前3 Constructing Generic AlgorithmsOPTION 1 Do as the standard does. Generally the standard follows convention: Do as the standard does. Generally the standard follows convention: 66 . 1PARAMETER ORDERING: OPTION 1 PARAMETER ORDERING: OPTION OPTION 1 Do as the standard does. Generally the standard follows convention: Do as the standard does. Generally the standard follows convention: 1. ExecutionPolicy comes first (if applicable) 66 . 1PARAMETER OPTION 1 Do as the standard does. Generally the standard follows convention: Do as the standard does. Generally the standard follows convention: 1. ExecutionPolicy comes first (if applicable) 2. first, last0 码力 | 145 页 | 8.44 MB | 6 月前3
 Conan 1.9 Documentationto /bin. The rest of the libraries should be found in the /lib folder, however, this is just a convention, and different layouts are possible. Install the requirements (from the mytimer/build folder) it will build “Hello” from the sources. • Builds and launches the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. 34 Chapter 5. Creating Packages don’t want to call conan create. This method will keep your build cache if you are using an IDE or calling locally to the conan build command. 5.4.1 Packaging Pre-built Binaries Running the build() method0 码力 | 470 页 | 3.05 MB | 1 年前3 Conan 1.9 Documentationto /bin. The rest of the libraries should be found in the /lib folder, however, this is just a convention, and different layouts are possible. Install the requirements (from the mytimer/build folder) it will build “Hello” from the sources. • Builds and launches the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. 34 Chapter 5. Creating Packages don’t want to call conan create. This method will keep your build cache if you are using an IDE or calling locally to the conan build command. 5.4.1 Packaging Pre-built Binaries Running the build() method0 码力 | 470 页 | 3.05 MB | 1 年前3
 Conan 1.8 Documentationto /bin. The rest of the libraries should be found in the /lib folder, however, this is just a convention, and different layouts are possible. Install the requirements (from the mytimer/build folder) it will build “Hello” from the sources. • Builds and launches the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. 34 Chapter 5. Creating Packages don’t want to call conan create. This method will keep your build cache if you are using an IDE or calling locally to the conan build command. 5.4.1 Packaging Pre-built Binaries Running the build() method0 码力 | 458 页 | 3.03 MB | 1 年前3 Conan 1.8 Documentationto /bin. The rest of the libraries should be found in the /lib folder, however, this is just a convention, and different layouts are possible. Install the requirements (from the mytimer/build folder) it will build “Hello” from the sources. • Builds and launches the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. 34 Chapter 5. Creating Packages don’t want to call conan create. This method will keep your build cache if you are using an IDE or calling locally to the conan build command. 5.4.1 Packaging Pre-built Binaries Running the build() method0 码力 | 458 页 | 3.03 MB | 1 年前3
 Conan 1.7 Documentationto /bin. The rest of the libraries should be found in the /lib folder, however, this is just a convention, and different layouts are possible. Install the requirements (from the mytimer/build folder) it will build “Hello” from the sources. • Builds and launches the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. Using Conan commands, the don’t want to call conan create. This method will keep your build cache if you are using an IDE or calling locally to the conan build command. 5.4.1 Packaging Pre-built Binaries Running the build() method0 码力 | 433 页 | 2.95 MB | 1 年前3 Conan 1.7 Documentationto /bin. The rest of the libraries should be found in the /lib folder, however, this is just a convention, and different layouts are possible. Install the requirements (from the mytimer/build folder) it will build “Hello” from the sources. • Builds and launches the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. Using Conan commands, the don’t want to call conan create. This method will keep your build cache if you are using an IDE or calling locally to the conan build command. 5.4.1 Packaging Pre-built Binaries Running the build() method0 码力 | 433 页 | 2.95 MB | 1 年前3
 The Surprising Costs of Voidcall f(arg) in some manner156 Note that __stdcall marker. It non-portably describes a non-C calling convention, which influences how arguments are passed to the function157 Notice that f almost has the but it uses the default (C language) calling convention158159 This does not compile; the function pointer passed to launch has an incorrect calling convention. Technically, if the compiler let us do0 码力 | 189 页 | 60.10 MB | 6 月前3 The Surprising Costs of Voidcall f(arg) in some manner156 Note that __stdcall marker. It non-portably describes a non-C calling convention, which influences how arguments are passed to the function157 Notice that f almost has the but it uses the default (C language) calling convention158159 This does not compile; the function pointer passed to launch has an incorrect calling convention. Technically, if the compiler let us do0 码力 | 189 页 | 60.10 MB | 6 月前3
 Conan 1.3 Documentationare copied in /bin the rest of the libraries should be found in the /lib folder. But it’s just a convention, different layouts are possible. Install the requirements (from the mytimer/build folder), and that it will build “Hello” from sources. • Build and launch the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. Using conan commands, the Generating the package PROJECT: Package folder C:\Users\conan\example_conan_flow\tmp\package PROJECT: Calling package() PROJECT package(): Copied 1 '.h' files: hello.h PROJECT package(): Copied 2 '.lib' files:0 码力 | 397 页 | 2.77 MB | 1 年前3 Conan 1.3 Documentationare copied in /bin the rest of the libraries should be found in the /lib folder. But it’s just a convention, different layouts are possible. Install the requirements (from the mytimer/build folder), and that it will build “Hello” from sources. • Build and launch the example consuming application, calling the test_package/conanfile.py build() and test() methods respectively. Using conan commands, the Generating the package PROJECT: Package folder C:\Users\conan\example_conan_flow\tmp\package PROJECT: Calling package() PROJECT package(): Copied 1 '.h' files: hello.h PROJECT package(): Copied 2 '.lib' files:0 码力 | 397 页 | 2.77 MB | 1 年前3
共 156 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16














