Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [templates]

The tag has no usage guidance.

-1
votes
0answers
44 views

Design Patterns to mitigate non-trivial conversions of user defined types

Background I've created a Template Factory class whose job it is to return std::function objects, created from static functions in order to use the Decorator pattern for DI in a stateful class. Let's ...
0
votes
0answers
119 views

c++ templates - combining deduction with default template arguments

I have a simple class (details here) namespace MemoizerSupport { template <typename T1, typename T2> using DEFAULT_CACHE = LRUCache<T1, T2>; } template <typename RESULT, ...
0
votes
1answer
43 views

Is it appropriate to have a template get “streamed” data while rendering?

I'm dealing with code that renders HTML pages. I'm cleaning up an old, messy PHP code base. Let's say I have a template that loops through a long list of rows in a database. I can load my data into ...
3
votes
4answers
205 views

C++ Preferred method of dealing with implementation for large templates

Typically when declaring a C++ class, it is best practice to put only the declaration in the header file and put the implementation in a source file. However, it seems that this design model does not ...
0
votes
1answer
52 views

What are the advantages of dynamic configuration based form templates?

When developing an application which presents the user with many similar forms for data entry, a common approach is to build a framework for defining the form structure in a standardised configuration ...
0
votes
1answer
134 views

Is there a coding style for Blade templates?

Since when I used smarty I always tried to separate logic statements from html tags, so my approach to blade would be to write: template.blade.php <div> <div> @if ($something == true)...
1
vote
1answer
85 views

Web Design Pattern For Displaying Dynamic Content

I currently have a WinForms app that uses XML documents to drive dynamic content that is shown to the user. I call these XML documents template files. The template file determines the features the ...
1
vote
1answer
208 views

Responsibility of message template for OTP microservice

We want to design a solution for generation and validation of OTP(One Time Password) process. We decided to create OTP process as a separate micro service. Since OTP need to be communicated to users ...
0
votes
1answer
162 views

T4 Template vs manual conversion in C#

I need to convert a large number of XML files into JSON. The XML files all have same structure, and differs only in data that they contain. I could write a basic C# utility that would parse XML and ...
0
votes
3answers
1k views

What approaches can be used to convert existing JSON structure to existing XML structure?

I am working on a component for an enterprise message queue that consumes a message from a queue and sends it as a text message. The message is picked up by my consumer in JSON format (I do not have ...
1
vote
1answer
62 views

Handling more specialized interface with no code duplication

I have the following code: struct AInterface { XXX some_method(/* some params */) = 0; }; void foo(const AInterface & a) { do_work(); while (x) { do_work_2(); ...
5
votes
2answers
624 views

When one should use template specialization, if not for metaprogramming?

When do we use template specializations for in C++, if not for SFINAE or metaprogramming? type_traits, enable_if and others rely on it a lot, but I'm more curious about situations which are more "...
1
vote
0answers
211 views

Dependency injection in the template class

I have a template wrapper class around the container std::priority_queue that supports multithreading. The short version of it is below. In this class I employ the function IsReady() that checks ...
3
votes
1answer
528 views

C++ generic graph search algorithm with generic data types

I'm trying to implement a generic graph search algorithm in C++, as part of assignment at university, and I encountered problems when trying to implement it, mostly struggling with templates. this is ...
0
votes
0answers
41 views

How to implement forms with almost same fieldsets used in two pages?

I use AngularJS 1.5. In my app I have a registration page(controller1 + template1) with form1. After registration user can change his data on his personal pages form2(controller2 + template2). The ...
3
votes
2answers
1k views

Was template meta programming really discovered “by accident”? [closed]

When I first saw this meme: I thought to myself, yeah right, but now I am not sure any more. So was template meta programming in C++ discovered by accident as the meme claims or was it intentional? ...
-1
votes
1answer
213 views

template restrictions in C++

I am creating a template class in C++ for numeric operations and I want to restrict it to only numbers or similar numeric types. My question is that is there any way in C++ to restrict a template ...
5
votes
1answer
3k views

Way for generating C# classes from existing C# class

I have simple POCO classes, like this: public class Book { public string BookId { get; set; } public string Name { get; set; } //etc... } I want to get all those classes and generate ...
0
votes
1answer
1k views

When do I use square brackets around routerLink in Angular2?

In Angular 2 (currently 2.0.0-rc.6), routerLink is used as a directive to indicate a path we wish to follow in our routing, e.g. in response to clicking a link. However, in the documentation both of ...
2
votes
2answers
260 views

C++ function (de)duplication in templatized classes

Please have a look at this code snippet: template<int N> class Foo { public: int f() { return N; } int g() { return 0; } }; Foo<3> a; Foo<4> b; I think it's compiler ...
-2
votes
1answer
231 views

What is an efficient way to implement 'Stack' without generics?

Today I was reading a lot of articles complaining about Java Generics or C++ Templates. Now, my question is: How can someone implement a collection data structure like Stack without using them?
7
votes
1answer
790 views

Can the C++ template system be used to perform type safe operations of the relational algebra

Assume that the parameters of functions representing operations of the relational algebra are represented by individual types: structs or classes. An operation such as (natural) join will have ...
0
votes
1answer
160 views

JavaScript templating trick or treat?

I've recently been looking into using JavaScript for templating and I was wondering about the legibility of using this approach. I understand that JavaScript templating is a very common and much ...
1
vote
1answer
215 views

Get or infer template type from inherited member

So I have an assignment from college where I have to apply multiple metaheuristics to different problems. I thought that I should make everything as modular and reusable as possible to reuse ...
2
votes
2answers
2k views

C++ Parametric Polymorphism

In the wikipedia article on Parametric Polymorphism, is the following commentary on C++. Can anyone explain what it's referring to when talking about "ad hoc aspects"? (I think it needs a citation)....
1
vote
0answers
219 views

User-editable templates for reporting: alternatives to word? [closed]

Not sure if this is the right platform for this, but here goes :) Throughout my career I have been generating reports for users, and most of the times it always started from a Word template (.dot/....
1
vote
2answers
828 views

Why are the smart folks who write and adopt react.js okay with the way markup is tightly-coupled/buried inside Javascript?

Quite a while ago there was a concerted trend in the industry to move towards adopting templating to separate markup from logic, or something like that. The result was much more pleasing to the eye ...
0
votes
1answer
197 views

Can I use an external Mustache template without Ajax?

I wrote up a site using Mustache to template it. Right now though, the template is embedded in the page, which defeats the purpose of using the template since I'll need to copy it to any other pages ...
1
vote
1answer
175 views

Is opening a templating engine to users a bad idea?

My site allows users to create custom HTML templates for their profiles (very much like Tumblr and the theme system), and I picked the Twig template engine for the site. However, I'm not sure if it'...
4
votes
1answer
9k views

Template Function: Passing Iterators

I am struggling with making a design choice in the following setup: I am writing (C++) functions which take a pair of iterators (to template containers) and compute a return value of the same type ...
5
votes
1answer
460 views

Command pipeline design question - where to place validation?

Here is the situation: I have a database and a class that is basically a representation of a set of fields of different tables in it. Let's call it Message. "Message" does not know of the database ...
1
vote
1answer
86 views

Templating a member name

I'm writing a library that provides graphs for search algorithms. Usually you want to rank nodes using a priority queue. Normally you want to search for an specific node in the queue and lower its ...
6
votes
1answer
413 views

Whether to abstract small repeating code segments in HTML templates?

(The framework used in question is AngularJS so the question can be translated as "Whether to introduce Directives for small repeating code segments in Views") As a developer who focuses on Java ...
21
votes
4answers
3k views

What about LISP, if anything, makes it easier to implement macro systems?

I'm learning Scheme from the SICP and I'm getting the impression that a big part of what makes Scheme and, even more so, LISP special is the macro system. But, since macros are expanded at compile-...
1
vote
1answer
5k views

C++ Templates where the type is a shared_ptr

When creating template classes in C++, if the type upon which the template will be specialized is intended to be a shared_ptr type, is it better to make T a shared_ptr type or make T a non-pointer ...
1
vote
2answers
2k views

What is the best approach for PHP mail templates

I'm working on a webshop (used to be for just one product, expanding it to multiple products and multiple shops hooked up to one backoffice, can't use PrestaShop because of compatibility). We send 3 ...
1
vote
1answer
312 views

C++ Template Metaprogramming and Call By Need Evaluation

I recently wrote a fairly complex C++ meta function that boils down to: template <size_t N, typename val> struct Rec { using type = typename std::conditional<N == 0, val, ...
0
votes
1answer
43 views

Scoping template variables in “has-a” (compositional) relationships

I'm developing a new templating language for PHP, and one of the features is an object-oriented approach to nested child templates. For example, I can declare an object of type HtmlBuilder like this: ...
0
votes
1answer
392 views

Bootstrap licence free template

I´m creating a new website. For that I´m using a free bootstrap template. On top of my index page I have: A Design by W3layouts Author: W3layout Author URL: http://w3layouts.com License: ...
1
vote
2answers
209 views

Why is it bad if view engines encourage logic in templates

I once read this, because I wanted to see if handlebars is the right view engine for me or rather something else. A thing that I wonder since then is the following, why is it considered bad, if a ...
42
votes
9answers
11k views

What did people do before templates in C++? [duplicate]

I am not new to programming, but I am one that started a few years ago, and I do love templates. But in the before times, how did people deal with situations where they needed compile-time code ...
1
vote
1answer
200 views

Would this be considered a plugin or template type architecture?

I would like to build a system that basically offers the option to make various APIs interchangeable for usage to the end user. For example, the person using the software would have the option of ...
2
votes
2answers
367 views

How can I get better than O(N^2) space complexity for a type sequence search?

Suppose I have a type sequence through which I want to search: template <typename...> struct TypeSequence { using type = TypeSequence; }; I want to create a metafunction Search that returns ...
6
votes
1answer
5k views

What are the main differences between C++ templates and Java generics? [closed]

I'm a beginning C++ programmer coming from Java. It feels to me that C++ templates and Java generics are actually pretty similar. You use them in pretty much the same occasions and in the same way. ...
0
votes
2answers
188 views

Can I create a type, typedef or using statement that results in a different type if instantiated a second time or more?

Suppose I have a class that evaluates some computationally intensive function: class Value { private: int eval() { mCached = ExpensiveOperation(); return mCached; } static int mCached;...
3
votes
1answer
1k views

Augmenting functionality of subclasses without code duplication in C++

I have to add common functionality to some classes that share the same superclass, preferably without bloating the superclass. The simplified inheritance chain looks like this: Element -> ...
19
votes
3answers
10k views

where exactly should python business logic be placed in django

I have just begun to learn Django/Python/Web Development. This problem has been troubling me for a while now. I am creating an application with multiple templates in Django. I have a views.py which ...
1
vote
2answers
170 views

Is it ok to start with templates in MVC development?

I'm new to web development and I've started working on a project in my company that uses DJANGO. I feel it flexible to start my development straight first from the templates. I think it will be easier ...
29
votes
10answers
5k views

Is template “metaprogramming” in Java a good idea?

There is a source file in a rather large project with several functions that are extremely performance-sensitive (called millions of times per second). In fact, the previous maintainer decided to ...
3
votes
1answer
336 views

Use a template to get alternate behaviour?

Is this a bad practice? const int sId(int const id); // true/false it doesn't matter template<bool i> const int sId(int const id) { return this->id = id; } const int MCard::sId(int ...