Contents
Aug 05, 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;
Apr 23, 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 :/
Jan 23, 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 :)
Jan 23, 2019 Hello World - 2
I haven’t been writing in human languages quite for a while, since college I think. I’ve gained tons of experience in programming in C++ and it’s right about time to start sharing experience. My plan is to write an article on practical programming about everty other week. That would be notes on implementing some concepts, mostly to systematise my experience. I hope those notes will turn out useful for someone else.
Jan 23, 2019 Clipper Round the World - Training
Jun 18, 2014 How to debug OAuth2 locally
The main problem when debugging web applications that use OAuth2 is that the other end (Google+, Facebook, Twitter etc) allows you to access their authorization services only from sertain production domains (which usually do not include localhost). Fast and dirty edits at the production server are not a good idea. And it is not as convinient as editing your files locally.
Jun 15, 2014 Hello World!
I have started this blog while digging into Boostrap, Backbone and other js stuff.