Advanced search
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.

Lila25milaJan. 28, 2019, 1:19 a.m.

DjangoИспользование Jinja2 с Django (начиная с 1.8)

Django, jinja, Python, template

На ресурсе Medium Corporation пользователь под ником Samu делится опытом использования Jinja2.
По его словам ранее он использовал Jinja2 в своих проектах, созданных с помощью Flask. Но затем решил использовать Jinja2 с Django для потенциального повышения производительности (в 10-20 раз быстрее по сравнению с шаблонами Django) и взаимодействия с Nunjucks.
Samu делится опытом с людьми, которые уже знакомы с данными технологиями, а его статья призвана немного раскрыть и упростить шаги.

ArrowJan. 27, 2019, 11:49 a.m.

DjangoИзменить имя формы в template для UpdateView

UpdateView, html, template

Добрый день!

На одной html странице нужно разместить два UpdateView. Для этого имя формы для одного хочу изменить на update_form, а второе на upd_form.

Стандартно в html файле UpdateView для формы использует имя form.

Код формы в html:

<form action="." method="POST">…
Evgenij LegotskojJan. 5, 2019, 9:49 a.m.

DjangoDjango - Tutorial 042. Caching templates for different types of content

templatetags, template, Django

In Django - Lesson 035. Different templates for rendering different types of content in search results it was shown how to render different templates depending on what type of content drawn in the search results on the site. In this case, the key point was that it was not necessary to make the verification conditions for the selection of the template. The information about the balbalon was stored in the variable TEMPLATE_PREVIEW, through which the template was inserted into the include tag in the Django template.

{% include object.TEMPLATE_PREVIEW %}

In this method there is one big drawback. The fact is that the include tag with each of its calls is looking for a template. With a large load on the site - this can significantly increase the duration of the response from the server. To solve this problem, you need to somehow cache the pattern. Since different types of content use different templates, to do this using inclusion_tag is quite problematic.

This problem was solved by caching the template at the class level as a class variable.

Evgenij LegotskojAug. 6, 2018, 2:52 a.m.

C++The idiom RAII and the principle of structured programming that a function must have one entry point and one exit point

template, lambda, C++11

The world of programming in C ++ in the new standards allows us to get up a variety of things, thanks to which we can safely abandon some old statements or principles, or simply flexibly approach these principles.

I would like to outline my view on the work of the RAII idiom and the C ++ 11 standard with respect to one established principle whose authorship is attributed to Edsger Dijkstra :

"The module (in this case the function) must have only one entry point and only one exit point"

For this principle, multiple returns in a function / method are contrary to the principles of structured programming for the following reasons:

  • the complexity of debugging code with the use of multiple returns returns increases with the number of these same return, that is, you never know when the function or method of an object just exited.
    the complexity of code support, when all the points of the call are not visible at the initial look at the function. Also, it is not known whether the code added to the end of the function will execute or not, especially if the program logic should always execute this code. That is, in the case of multiple returns, you will have to implement this code before every call to the return operator.

But modern C ++ has already changed significantly since the times of Dijkstra and the means of the latest C ++ standards allow to bypass or significantly level out the influence of the reasons that caused the formulation of the principles of structured programming.

Evgenij LegotskojJuly 5, 2018, 3:05 a.m.

DjangoDjango - Tutorial 035. Different templates for rendering different types of content in the search results

Django, template, content, Search

Constant visitors of the site who use the search on the site, probably noticed that the display of articles differs from displaying comments in the search engine issue of the site. This was achieved by the fact that each content type has its own template for rendering, which is substituted for the rendering of the page, depending on what content was found in the search.

Let's look at the example of issuance.

You see, here the presentation of the comment differs from the article, but they are output in the framework of one search issue, as was done in the previous article.

But this is done much more elegantly than selecting via if else . Honestly, I myself really like this decision.

Evgenij LegotskojSept. 18, 2016, 3:41 a.m.

DjangoDjango - Tutorial 003. Model, Template, View on Django

view, model, template

In Django uses a modular system of applications, where one application is composed of several applications, each responsible for its functionality. As you have noticed, at the time of this writing, the site has a section "Knowledge", in which there are several sections, which have divided the article.

When working with the previous site on Wordpress, mindlessly spend time on the addition of new articles to the list of lessons on Qt. On this same site the page is automatically generated and save a new article is published with the status, this article will automatically enters the relevant section of the list.

I suggest to understand how it is implemented in a minimal version of the example EVILEG COM.


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:60points,
  • Rating points-1

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

  • Result:70points,
  • Rating points1

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

  • Result:71points,
  • Rating points1
Popular publications in the last 90 Days
Last comments

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

а как быть если нет базы и запроса в БД, а данные приходят по запросу в api стороннего сервера, а клиент серверное приложение на django и я хочу реализовать пагинацию на стороне django. В апи я …
  • ethen
  • Aug. 28, 2021, 3:49 p.m.

Release of the C++/Qt and QML application deployment utility CQtDeployer v1.5.0

Благодарю. Действительно, подменил файлы от версии 4.0, и все заработало)

Release of the C++/Qt and QML application deployment utility CQtDeployer v1.5.0

На данный момент Qt Installer Framework не поддерживает Windows 7 смотрите баг #2224
  • 4X_Pro
  • Aug. 26, 2021, 7:32 a.m.

Распознавание изображений на Python с помощью TensorFlow и Keras

Понимаю. А ещё понимаю, что не потратить время нельзя. День всё равно пройдёт, и вопрос только в том, на что он будет потрачен: на то, что приносит в жизни удовольствие или нет. Насчёт заст…

Qt/C++ - Lesson 023. Moving QGraphicsItem on QGraphicsScene with mouse help

здравствуйте! Подскажите, пожалуйста, как можно на Вашем примере реализовать вывод контекстного меню при нажатии на квадрат правой кнопкой мыши с целью решения задач: изменить объект и удалить? …
Now discuss on the forum

HTTP server на Qt

Мой файл webapp1.ini [listener];host=…

QScrollArea dynamically add QCheckBoxes

Всё правильно. Это просто спамер, который отправился в вечный бан.
  • ad40
  • Sept. 15, 2021, 3:32 a.m.

Qt proxyModel

Добрый день! Разобрался с задачей! (иногда отвлеченное участие приводит к нахождению решения , так что не могу не выразить благодарность участникам данного форума) Все оказаолось дов…

Update data | Django, Ajax

Привет, добрался я к реализации системы общения, тут как раз получилось что попал на ваши статейки, все работает как часы, но осталась одна маленькая деталь, как обновлять сообщения в диалоге и …

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

Всем здравствуйте. Незамысловатая задача появилась у меня - вызвать функцию Python с Qml. Смотрел уроки на этом сайте, но что-то я не понимаю. Сверял код Qt C++, вроде как всё также, …
© EVILEG 2015-2021
Recommend hosting TIMEWEB