Advanced search
Evgenij LegotskojAug. 22, 2019, 3:42 a.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 LegotskojFeb. 26, 2019, 5:22 a.m.

C++Using SFINAE to specialize template methods, depending on the type of container std::map or std::vector, passed as an argument

SFINAE, C++17, template

There was a problem: "write the second implementation of the template function", in which the same arguments are passed. That is, the signature of both functions completely coincides. The difference is that, as an argument, the std::vector containers and the std::map containers can be passed to the function. And depending on whether std::vector is or std::map, this or that implementation should be selected.

In this case, the SFINAE rule will be used, which states: If the final types of arguments cannot be calculated (to perform substitution of template parameters) of an overloaded template function, the compiler does not throw an error, but searches for another suitable overload. The error will be in three cases:

  • No suitable overload was found.
  • Several such overloads were found, and C ++ cannot decide which one to take.
  • The overload was found, it turned out to be a template, and an error occurred when instantiating the template.

Our case will be the second. There are two overload template functions.

Evgenij LegotskojOct. 23, 2018, 6:11 a.m.

C++C++ 17 - [[fallthrough]] attribute

cpp, C++17, fallthrough

Start at work to use a compiler that supports the standard C++17.

Actively we begin to use various features from this standard..

I was pleased with the [[fallthrough]] attribute for switch case constructions.

Timeweb

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
s

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

  • Result:42points,
  • Rating points-8
e
  • enfant
  • Oct. 14, 2021, 2:59 p.m.

C++ - Test 002. Constants

  • Result:75points,
  • Rating points2
e
  • enfant
  • Oct. 14, 2021, 2:54 p.m.

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

  • Result:93points,
  • Rating points8
Popular publications in the last 90 Days
Last comments
s

Qt/C++ - Lesson 060. Configuring the appearance of the application in runtime

Добрый вечер, на "лету" не работает, только перезапуск
s

Qt/C++ - Lesson 060. Configuring the appearance of the application in runtime

Спасибо, завтра опробую и отпишусь по результату

Django - Tutorial 007. Adding Pagination based on django-bootstrap3

Просто список каких-нибудь объектов передавайте, который дёрнули ищ api стороннего сервера from django.core.paginator import Paginatorobjects = ['john', 'paul', 'george', 'ringo']p = Pagina…
b

PyQt5 - Tutorial 009. Using QThread with MoveToThread

Спасибо большое

PyQt5 - Tutorial 009. Using QThread with MoveToThread

Вызвать либо метод quit() либо эквивалентный его вариант - метод exit(0)
Now discuss on the forum
  • Nomad
  • Oct. 15, 2021, 6:39 a.m.

Вопрос из раздела "как реализовать"

Всем привет. Есть бизнес логика которую надо реализовать на джанге, она состоит в следующем: надо реализовать функционал регистрации/авторизации компаний у которого есть свой дашборд …

Проблема с созданием файлов перевода для составного проекта

Я имею ввиду, если у вас был старые ts файлы, то написать парсер, который составил бы словарь переводов. Например. "Hello world" - "Привет мир" "Hello dev" - "Привет dev" и…
k

QPsql Компиляция драйвера

при компиляции драйвера из окна Qt 5.15.2 (MSVC2019 64 ) надо было запустить C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat тогда компиляция вып…
P
  • Pisych
  • Oct. 12, 2021, 10:59 p.m.

Фильтр в Select формы Django

Добрый день! Подскажите, как можно сделать? Есть форма, связанная с моделью. В форме Select, выбор типа документа (Приход, Расход,Списание). Этот Select берет данные из таблицы типов документов.…

Вызов функции Python с Qml

Чтобы onResult в QML подключилось к чему-то в Python, нужно чтобы result было сигналом, а у вас это слот. В качестве сигнала определено takeFunc и в данном случае в QML должно ра…
About
Services
© EVILEG 2015-2021
Recommend hosting TIMEWEB