Aug. 22, 2019, 3:42 a.m.


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.

Aug. 21, 2019, 5:45 a.m.


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.

Aug. 21, 2019, 3:56 a.m.


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.

May 12, 2017, 1:06 p.m.


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.


Hello, Dear Users of EVILEG!!!

If the site helped you, then support the development of the site financially, please.

You can do it by following ways:

Thank you, Evgenii Legotckoi

Jan. 27, 2020, 5:10 a.m.
Sergei Filin

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

  • Result:73points,
  • Rating points1
Jan. 25, 2020, 1:16 p.m.
Bekzod Muminov

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

  • Result:53points,
  • Rating points-4
Jan. 25, 2020, 1:04 p.m.
Bekzod Muminov

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

  • Result:20points,
  • Rating points-10
Last comments
Jan. 27, 2020, 9:53 a.m.

Единственная проблема состоит в том, что для выделения QCheckBox приходится дважны нажимать мышь. Получается что сначала выделяется ячейка. а только потом фокус уже попадает на виджет. …
Jan. 27, 2020, 1:01 a.m.
Ruslan Polupan

Да так, посмотрел библиотеку попробовал примеры...
Jan. 26, 2020, 2:51 p.m.

Чего не webassembly?
Jan. 21, 2020, 2:12 p.m.

Полезная статья. Как всегда - то что надо. Добавлю ещё маленькую полезность - после установки tracer (88 строка) и перед выводом значений в lineEdit (91 строка) стоит добавить updatePositio…
Jan. 17, 2020, 2:31 a.m.
Andrej Jankovich

Выглядит как ошибка библиотеки. Расскажите подробно на какой платформе вы собираете проект (MinGW или MSVC) их версии и версии Qt.
Now discuss on the forum
Jan. 27, 2020, 3:17 a.m.
Il'ja Chichak

а почему бы не сделать одну модель, например Attachement со всеми этими полями, и в зависимости от действия пользователя, например, "добавить документ", "добавить картинку" и т.д. класть все это…
Jan. 26, 2020, 11:42 a.m.

Другого способа, как получать перезагруженный контент через JavaScript на странице, я не знаю. Получилось сделать без QWebEngineView, с помощью QWebEnginePage, runJavaScrip…
Jan. 26, 2020, 11:14 a.m.

Да, я не понял до конца того, как это работает, мало опыта работы с qt и QVAriant ни разу не использовал. Спасибо за помощь)
Jan. 26, 2020, 4:11 a.m.
Vladimir Zhitkovsky

Да, спасибо порешалось таким образом: удаление одного for(int i = 0; i < lstData.count(); ++i){ auto *data= dynamic_cast<Data*>(lstData[i]); if(data) { if(…
Jan. 14, 2020, 9:04 a.m.
Ruslan Volshebnik

Проблема осталась. Но я выснил, что это происходит когда файл достигает максимального размера.
© EVILEG 2015-2019
Recommend hosting TIMEWEB