int quote_delims = 100'000'000;
int float_delims = 100.00'00;
int hex_delims = 0xFF'Fa12;
int bin_delims = 0b10'1000;

// string literal with encoding-prefix
char str1[] = u8"UTF-8 string";
char16_t str2[] = u"UTF-16 string";
char32_t str3[] = U"UTF-32 string";

// Raw string literal
char raw_str1[] = R"(foo
bar
baz)";
char raw_str2[] = R"delim(\w+ \d+)delim";
char16_t raw_str3[] = uR"(\w+ \d+)";

// time literal
#include <chrono>
using namespace std::chrono_literals;
auto oneDecade = 10y;
auto oneYear = 365.2'425d;
auto oneDay = 24h;
auto halfAnHour = 30min;
auto oneYearInMins = 525'949.2min;
auto halfAnHour = 0.5h;
auto oneMin = 60s;
auto oneSec = 1000ms;
auto oneMilliSec = 1000us;
auto oneMicroSec = 1000ns;

// complex literal
#include <complex>
using namespace std::complex_literals;
auto complexNumber = 1 + 1i;
auto complexNumberl = 1 + 1il;
auto complexNumberf = 1 + 1if;

// null pointer
int *a = nullptr;

// bit field
struct S {
    // will usually occupy 2 bytes:
    // 3 bits: value of b1
    // 2 bits: unused
    // 6 bits: value of b2
    // 2 bits: value of b3
    // 3 bits: unused
    unsigned char b1 : 3, : 2, b2 : 6, b3 : 2;
};
std::cout << sizeof(S) << '\n'; // usually prints 2

// loops
int n = 10;
while (n --> 0) {
  std::cout << n << '\n';
}
for (int &i : {1, 2, 3, 4}) {
  std::cout << i << '\n';
}

// decltype
int num = 1;
decltype(num) total = num;
struct A { double x; };
const A *a = A {0};
decltype(a->x) ax = a->x;

// strongly typed enums
enum class Day {
    Mon, Tue, Wed, Thur, Fri, Sat, Sun
};
Day today = Day::Mon;

// lambda function
auto add = [](int x, int y) { return x + y; };
auto noParam = [] { return 5; };
auto invokeNow = [](int x) { return x * 5; }(1);
int captureMe = 5;
auto byCopy = [captureMe] { return captureMe; };
auto byRef = [&captureMe] { return captureMe; };
auto allByCopy = [=] { return captureMe; };
auto allByRef = [&] { return captureMe; };
auto increment = [y = 1](int x) { return x + y; };
double distance = [](double x, double y, double xx, double yy) -> double {
  return abs(x-xx) + abs(y-yy);
};

// templates
namespace N
{
    template<class T>
    class Y // template definition
    {
        void mf() { }
    };
}
template class N::Y<char*>;
template void N::Y<double>::mf();
template struct Z<double>;
template<typename T> concept C1 = sizeof(T) != sizeof(int);
template<C1 T> struct S1 { };
template<C1 T> using Ptr = T*;
template <typename, typename...>
template<class...> struct Tuple { };
template<typename ...Ts> void f(Ts...) {}

// variadic template
template<class F, class... Args>
void forward_args(F f, Args... args) {
    f(std::forward<Args>(args)...);
}

// namespace
namespace printing {
    inline namespace latest {
        using std::cout;
        void print() {
            cout << "Latest print\n";
        }
     }
     namespace old {
          void print() {
              ::printf("Old print\n");
          }
     }
}
printing::print();
printing::latest::print();
printing::old::print();
namespace oldPrint = printing::old;
oldPrint::print();

// attribute
[[noreturn]] void throwError() { throw "error"; }
[[deprecated("useless")]] void doNothing() {}

namespace std {
    class thread {
    public:
        // types:
        class id;
        typedef void *native_handle_type;

        // construct/copy/destroy:
        thread() noexcept;
        template <class F, class ...Args> explicit thread(F&& f, Args&&... args);
        ~thread();
        thread(const thread&) = delete;
        thread(thread&&) noexcept;
        thread& operator=(const thread&) = delete;
        thread& operator=(thread&&) noexcept;

        // members:
        void swap(thread&) noexcept;
        bool joinable() const noexcept;
        void join();
        void detach();
        id get_id() const noexcept;
        native_handle_type native_handle();

        // static members:
        static unsigned hardware_concurrency() noexcept;
    };
}

// try-block
try {
    throw std::runtime_error("Runtime error!");
} catch (std::exception& e) {
    std::cerr << e.what() << std::endl;
}

constexpr int factorial(int n) {
    return n > 0 ? n * factorial(n - 1) : 1;
}

/* foo */ #if 0
    this is commented
#endif

/* it shouldn't hang */        /* trying to lex this */
/*{"ahg/awn/xan?",     HB_TAG('A','G','W',' ')},*/     /* Agaw */
/*{"gsw?/gsw-FR?",     HB_TAG('A','L','S',' ')},*/     /* Alsatian */
/*{"krc",      HB_TAG('B','A','L',' ')},*/     /* Balkar */
/*{"??",       HB_TAG('B','C','R',' ')},*/     /* Bible Cree */
/*{"sgw?",     HB_TAG('C','H','G',' ')},*/     /* Chaha Gurage */
/*{"acf/gcf?", HB_TAG('F','A','N',' ')},*/     /* French Antillean */
/*{"vls/nl-be",        HB_TAG('F','L','E',' ')},*/     /* Flemish */
/*{"enf?/yrk?",        HB_TAG('F','N','E',' ')},*/     /* Forest Nenets */
/*{"fuf?",     HB_TAG('F','T','A',' ')},*/     /* Futa */
/*{"ar-Syrc?", HB_TAG('G','A','R',' ')},*/     /* Garshuni */
/*{"cfm/rnl?", HB_TAG('H','A','L',' ')},*/     /* Halam */
/*{"ga-Latg?/Latg?",   HB_TAG('I','R','T',' ')},*/     /* Irish Traditional */
/*{"krc",      HB_TAG('K','A','R',' ')},*/     /* Karachay */
/*{"alw?/ktb?",        HB_TAG('K','E','B',' ')},*/     /* Kebena */
/*{"Geok",     HB_TAG('K','G','E',' ')},*/     /* Khutsuri Georgian */
/*{"kca",      HB_TAG('K','H','K',' ')},*/     /* Khanty-Kazim */
/*{"kca",      HB_TAG('K','H','S',' ')},*/     /* Khanty-Shurishkar */

class Base
{
public:
    Base () = default;
    virtual ~Base () = default;

    virtual void foo () = 0;
};

class Derived final : public Base
{
public:
    Derived () = default;
    virtual ~Derived () = default;

    virtual void foo () override
    {
        auto a = 1 + 2;
    }
};

#define foo bar
#define baz zot

class Highlighter : public QSyntaxHighlighter
{
    class InnerClass {}

    Q_OBJECT

public:
    Highlighter(QTextDocument *parent = 0);

protected:
    void highlightBlock(const QString &text);

private:
    struct HighlightingRule
    {
        QRegExp pattern;
        QTextCharFormat format;
    };
    QVector<HighlightingRule> highlightingRules;

    QRegExp commentStartExpression;
    QRegExp commentEndExpression;

    QTextCharFormat keywordFormat;
    QTextCharFormat classFormat;
    QTextCharFormat singleLineCommentFormat;
    QTextCharFormat multiLineCommentFormat;
    QTextCharFormat quotationFormat;
    QTextCharFormat functionFormat;
};

switch (foo) {
    case Foo::kBar:
        break;
}
