Sergei Fedorov
aka zmij

If you can imagine it, you can achieve it.
If you can dream it, you can become it.

William Arthur Ward

about me

About

My name is Sergei Fedorov, I am 41, I live in Moscow, Russia. I've got a beautiful wife and two adorable sons.

I'm a programmer, a motorcyclist, a sailor and a salsa dancer :)

read more

Latest posts

Last 3 posts

05 Aug 2022 Handling Member Pointers in Template Args

I always forget how to handle member pointers in templates, so here is a recipe:


template <auto>     // since C++17
struct my_template; // Primary template, no definition

template <typename Class, typename ResultType, ResultType Class::* Member>
struct my_template<Member> {
    // optional type aliases
    using class_type = Class;
    using member_type = ResutlType;

    static constexpr auto member = Member;
    // code here
};

For C++20 a non-type concept (cannot be used instead of typename) can be defined as follows:

template<auto P>
concept member_data_pointer = std::is_member_object_pointer_v<decltype(P)>;

template <auto P>
concept member_func_pointer = std::is_member_function_pointer_v<decltype(P)>;

How to use this concept to constrain templates:

// Constraining primary template
// Usable to constrain all specialisations to member data pointers
template <auto P>
requires member_data_pointer<P>
struct my_template;

template <auto P>
struct my_cool_template; // Primary template to handle both data and function members

// Constraining template specialisation to member data pointers
template <typename Class, typename ResultType, ResultType Class::* Member>
requires member_data_pointer<Member>
struct my_cool_template;

// Constraining template specialisation to member function pointers
template <typename Class, typename MemberType, typename... Args, MemberType (Class::*Member)(Args...)>
requires member_func_pointer<Member>
struct my_cool_template;

read more...

23 Apr 2020 Easy Join Zoom Meeting the Hard Way

I've got tons of zoom meetings every day, links to the meetings are in my calendar. Usually the flow is as follows:

    • notice event notification
      go to calendar app
      find the meeting
      open meeting details
      click the zoom meeting link
      wait for Safari to open the page and show the dialog to open zoom
      click on the allow button
      wait for zoom to join meeting
      ...
      profit :/
  • read more...

    23 Jan 2019 Why 'psst' namespace

    Some time ago I was working in a studio named “Pushkin Game Studio” and at some point we decided to opensource some libraries that we developed for our projects and that don’t contain business-related code. At first we put all the code in namespace tip, the codename for the project we were developing when we started the libaries. The namespace is still used in several libraries. Some libraries were too generic and we decided to put them into thier own namespaces. But later the project was closed, we started another one and the tip namespace became totally irrelevant.

    So the newer libraries used namespace psst, which initially stood for PuShkin Studio Templates, as the first library using this namespace was a collection of metaprogramming utilities. I left the studio in August 2018, but I continue to support and develop the libraries as I love the sound the namespace is pronounced :)

    read more...