Obscure C++ Features

  • Thread starter Thread starter pingu
  • Start date Start date
Code:
    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?

Code:
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

Last edited:
What's going on here?

Code:
    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 Bottom