Advanced search
Evgenij LegotskojAug. 22, 2019, 1:42 p.m.

C++C ++ 17 - Lazy template functor with caching heavy function computation result

C++17, lambda, auto, functor

Developing the idea of caching the result of calculations of heavy functions , I propose to write a small template class, which will take the function as an argument, namely the lambda function, as the most universal an instrument within which a heavy function will be performed.

In this case, the result of the function will not be calculated at the time of creation of the Functor, but at the time of calling the operator parentheses () . And at the same time, the result will be cached. That will allow not to call a heavy function more than once as part of the execution of a method.

Evgenij LegotskojAug. 21, 2019, 3:45 p.m.

C++C++14 - lambda function with cached return value

lambda, auto, cache, C++14, C++

Suppose we wrote a function that calculates some value or uses a function to calculate this value, while the function_ which calculates the value is quite expensive to calculate and works for a long time. In this case, we call the lambda function several times in some code.

To avoid multiple calls to the heavy function, we can cache the value that the heavy function returns.

Evgenij LegotskojAug. 21, 2019, 1:56 p.m.

C++C++14 - unnamed structure as auto value returned by function

C++, C++14, auto, lambda

Let's look at an interesting construction from the C++14 standard, which allows you to return the structure used in one place of the code, but you need to return an object with named fields.

Such a construction can serve as a replacement for std::tuple. At the same time, we will not need to declare any additional structures that we are not going to transfer anywhere, since we need to get only a set of data that we will somehow use immediately at the place of return and will not transfer further in the same form.

Evgenij LegotskojMay 12, 2017, 11:06 p.m.

C++C++ - Tutorial 002. Types, Variables and Arithmetic

C++, int, char, double, auto, nullptr

Each variable or expression has its own data type, for example, an declaration

int some_variable;

Indicates that the variable some_variable has an integer type int .

The declaration allows you to enter a variable in the program. This variable will have a certain type of data: integer, floating point, character in the case of basic data types, or custom type (data structure, class). The type of the variable defines the set of operations that can be performed on the variable. The declaration of a variable determines the allocation of the memory area that is required for it. And also the value of this variable, which from the computer's point of view will be a sequence of bits. The declaration of a variable also carries the name by which the programmer will refer to this variable in the program code.

In the above example, we have a variable that has a base integer type, with which arithmetic operations, comparison, assignment, etc. can be performed. Refer to the code in this code by this name by some_variable.


Let me recommend you the excellent hosting on which EVILEG is located.

For many years, Timeweb has been proving his stability.

For projects on Django I recommend VDS hosting

View Hosting

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4

C++ - Test 001. The first program and data types

  • Result:73points,
  • Rating points1

C++ - Тест 003. Условия и циклы

  • Result:57points,
  • Rating points-2
Last comments

Django - Tutorial 001. Deploying a site on Django + PostgreSQL + Gunicorn + Nginx

А почему нельзя? Где можно об этом почитать? Киньте, пожалуйста, в меня ссылкой.

Django - Tutoral 049. Optimizing Django Performance with a Real Project

Огромное спасибо вам за статью! Для меня стали открытием select_related и prefetch_related
  • t1m4
  • Feb. 24, 2021, 1:56 p.m.

Django - Tutorial 052. Redefining a User Model

В данном случае я заходил под superuser но все равно не появлялись эти поля

Django - Tutorial 001. Deploying a site on Django + PostgreSQL + Gunicorn + Nginx

Поднял сервис с помощью systemd, вот по этому мануалу:
  • t1m4
  • Feb. 23, 2021, 6:11 p.m.

Django - Tutorial 052. Redefining a User Model

А как дать ему эти права?
Now discuss on the forum

как добавить списки в список, которые созданы динамически

Привет всем! Смотрите новое: лучшие онлайн казино россии - За регистрацию предоставляют до 225 фриспинов бесплатно + 100% бонуса до 500$ на первый д…

Не отдаётся статика на виртуальной машине

В итоге выставил 775 на все файлы проекта и всё заработало. Но я не уверен, что так правильно.
  • Pisych
  • March 3, 2021, 12:06 p.m.

Вывод данных из связанных таблиц.

Не знаю, правильно ли... Но работает <body>{% for i in CatList %} <ul> <li><h3>{{i.title}}</h3></li>{% for j in ProdList %}<ul>{…

нужна помощь с проектом qt c++

дали задание, на несколько дней. собираюсь делать, но хотел бы получить помощь более опытных людей, чтобы подкорректировать себя и подстраховаться. каким образом это можно сделать? …

QScrollArea dynamically add QCheckBoxes

Всё правильно. Это просто спамер, который отправился в вечный бан.
© EVILEG 2015-2020
Recommend hosting TIMEWEB