Небольшое пособие по перегрузке операторов в C++.
Для примера рассмотрим класс
class Example {
std::vector<int> values;
public:
https://docs.google.com/presentation/d/1_Wwpgf2Z18xn4U1odHOHKwMHiwYDqj2X8Fh24RybxdE/edit?usp=sharing |
//#include <library/unittest/registar.h> | |
#include <tuple> | |
#include <string> | |
#include <iostream> | |
template <typename T> | |
void print(const T& t); | |
template <typename... T> |
#include <iostream> | |
#include <type_traits> | |
#include <cassert> | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
class StreamImplBase { | |
public: | |
virtual void* input_raw() = 0; | |
}; |
#include <stdio.h> | |
int main(int s) { | |
switch (s) { | |
case 1: | |
printf("Вот дом,\n"); break; | |
case 2: | |
printf("\nА это пшеница,\n"); break; | |
case 3: | |
printf("\nА это весёлая птица-синица,\n"); break; |
# -*- coding: utf-8 -*- | |
from __future__ import print_function, absolute_import, division | |
import re | |
from statbox_abt_metrics.meta import Meta | |
from yandex_inflector_python import Inflector |
# -*- coding: utf-8 -*- | |
""" | |
This module implements a threadlocal-like class that is local | |
for asyncio tasks. This is suboptimal and we're fin with it | |
(at least for now). | |
Waiting for a native implementation proposed in pep-0550. | |
""" |
#ifndef __HASHMAP_H__ | |
#define __HASHMAP_H__ | |
#include <iostream> | |
#include <vector> | |
#include <list> | |
#include <utility> | |
#include <algorithm> | |
#include <functional> |
from funcparserlib.lexer import make_tokenizer, Token, LexerError | |
from funcparserlib.parser import some, a, maybe, many, finished, skip, \ | |
forward_decl, NoParseError | |
const = lambda x: lambda _: x | |
tokval = lambda x: x.value | |
toktype = lambda t: some(lambda x: x.type == t) >> tokval | |
op = lambda s: a(Token('Op', s)) >> tokval | |
op_ = lambda s: skip(op(s)) |