• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Obscure C++ Features

C++:
    using A = std::decay<int>::type;         
    using B = std::decay<int&>::type;        
    using C = std::decay<int&&>::type;       
    using D = std::decay<const int&>::type;  
    using E = std::decay<int[2]>::type;      
    using F = std::decay<int (int)>::type;    

    using G = std::decay<volatile int>::type;         
    using H = std::decay<const volatile int&>::type;
 
These are all fairly basic and well-documented.
Not obscure RTFM :D

Most vexing parse
????
Agreed. The only C++ I regard as obscure is stuff I found in Mark Joshi's book on pricing patterns using stuff so obscure even STL experts find it obscure. Unsurprisingly I never used it in industry as it was all a bit too obscure.
Funky looking stuff but unless it's going to make an algorithm run 10x times faster I couldn't care less.
 
Funky looking stuff but unless it's going to make an algorithm run 10x times faster I couldn't care less.

C++11/C++14 is shifting in the direction of compile-time polymorphism and away from subtype polymorphism to a) reduce code bloat b) improve performance over virtual functions c) catch bad designs and errors at compile-time.
 
"Yes, seriously, C++17 brings std::variant. This is cool, and paves the way for future features building upon variant and other related ideas. Such as pattern matching, [...] std::variant is designed with the experience of boost::variant and other variant libraries."
 
Why does this code not compile?

C++:
struct C
{
        C() = default;

        template <typename... Args>
            C(Args... args)
        {
       
        }
};
 
Some C++11 to show the use of higher-order functions. Close to maths.
C++ is an extremely flexible language.
 

Attachments

  • TestHOF101.cpp
    2.2 KB · Views: 31
Last edited:
What's going on here?

C++:
    double S = 2.0; double K = 65.0; double h = 1.0;

    double sum = 0.0;
    for (int i = 1; i <= 100; ++i)
    {
        sum += std::sqrt(S / K); S -= h;
        std::cout << i << ",";
    }

    std::cout << std::boolalpha << "Sum: " << sum << '\n';
 
Back
Top