Talk type: Talk

C++ tricks from Yandex.Taxi

  • Talk in Russian
Presentation pdf

When writing large frameworks, one has to face typical problems, solutions for which have long been known. However, these solutions are not effective enough and can be implemented much better.

We will talk about such effective tricks!

  1. There is a famous Pimpl pattern:
struct something {

int foo ();

private:

struct impl;

std :: unique_ptr < const impl> impl_; // dynamic allocation :(

};

Let's remove the dynamic allocation from it and add cache friendliness.

  1. Logging of user types:
std :: ostream & operator << (std :: ostream & os, const user_data_type & udt);

my_debug_logger << user_data_type {"foo", "bar"};

Let's do it without std::ostream and without calculating the values of variables for the records that we do not log.

  1. Conversion from JSON/XML/YAML/... into user-provided types:
// This does not compile:

user_data_type1 Parse (const Json & value);

user_data_type2 Parse (const Json & value);

// Compiles, but...

template < class T> T Parse (const Json & value);

template <> user_data_type1 Parse (const Json & value);

template <> user_data_type2 Parse (const Json & value);

// ... gives us horrible unreadable error messages, and Parse<std::vector>(const Json & value) is odd.

Let's make it beautiful.

  • #adl
  • #fastpimpl
  • #logging
  • #pimpl

Speakers

Talks