Click here to Skip to main content
15,881,675 members
Everything / Templates

Templates

templates

Great Reads

by Bruno van Dooren
How concepts can be used in template programming for partial specialization
by Kunal Chowdhury «IN»
Customized Scrolling in Silverlight using Expression Blend
by Vincent Maverick Durano
The new version of ApiBoilerPlate has recently been released. In this post, we will take a look at the new features added to the template.
by Anton Chibisov
This tutorial showcases how to implement C++ delegates which are capable of being bound to methods and functions having arbitrary signature, i.e., any number and type of parameters and return value.

Latest Articles

by Bruno van Dooren
Ways to enforce an interface contract on static methods, similar to what you would expect from static virtual methods if they'd exist in C++
by Bruno van Dooren
How concepts can be used in template programming for partial specialization
by Bruno van Dooren
This article describes a way to hash data using the latest Win32 API and C++
by honey the codewitch
Make your projects far more powerful with some foundational code templating techniques

All Articles

Sort by Score

Templates 

8 Sep 2022 by Bruno van Dooren
How concepts can be used in template programming for partial specialization
13 Nov 2010 by Kunal Chowdhury «IN»
Customized Scrolling in Silverlight using Expression Blend
1 Dec 2019 by Vincent Maverick Durano
The new version of ApiBoilerPlate has recently been released. In this post, we will take a look at the new features added to the template.
13 Apr 2015 by Anton Chibisov
This tutorial showcases how to implement C++ delegates which are capable of being bound to methods and functions having arbitrary signature, i.e., any number and type of parameters and return value.
23 Mar 2021 by honey the codewitch
Make your code more efficient by hacking your compiler to improve its optimization capabilities
26 Aug 2022 by Bruno van Dooren
This article describes a way to hash data using the latest Win32 API and C++
28 Oct 2021 by honey the codewitch
Make your projects far more powerful with some foundational code templating techniques
16 Jul 2015 by Shivprasad koirala
In this article, we will demonstrate Template Pattern reusing ADO.NET.
14 Jul 2014 by Kornfeld Eliyahu Peter
How to access controls created from ASP.NET template...
18 Oct 2020 by Espen Harlinn
An introduction to C++ 20 concepts
24 Nov 2011 by Scanix
SystemFramework defines interfaces, classes, and types to support a native runtime system with its own garbage collector, delegates, etc. The design of SystemFramework classes is similar to those of the .NET Framework.
18 Oct 2014 by CubbiMew
Since data is an out-parameter (you're trying to populate it within genRand and make the result available in the caller, right?), you need to take it by reference:templatevoid genRand(T& data, int size){ ...genRand(smallVector, smallSize);genRand(smallArray,...
28 Oct 2021 by honey the codewitch
This is a little templating engine build tool I use to make my code generation projects more maintainable.
23 Jun 2012 by Leland Richardson
How to dynamically create item templates on the server-side in ASP.NET.
22 Feb 2011 by wpfdev
This blog post is re-posted from www.eriklieben.com. Looking at the file tab of Word 2010, I’ve wondered if a WPF tab control could be transformed to this layout. At first, this felt like something that could never be done, without doing a lot of magic or building it from scratch...
7 Mar 2013 by Weidong Shen
This article describes the IClientChangeTracking interface generated by Self-Tracking Entity Generator and Visual Studio 2012.
3 Mar 2013 by Lukasz Gwizdz (Member 2097797)
I think that with following you can go back to version with two constructors:class my_class{ // A, B and C types defined elsewhere... typedef std::shared_ptr a_ptr_type; typedef std::shared_ptr b_ptr_type; typedef std::shared_ptr c_ptr_type; ...
12 Jul 2013 by David O'Neil
VS 2012 gives an 'error C2248: ... cannot access protected member declared in class...' in the following minimal code stripped from a complete project. VS 2008 has no problems with it, and executes as expected.The line right before the issue calls the protected member in question, and no...
13 Jul 2013 by pasztorpisti
Unfortunately I have no VS2012 at hand but I have a g++ that has always been my friend when I wanted to check whether a piece of code follows the standard or not. Using my VS2010 and g++4.5 (cygwin) I have put together the following example program that may serve you with some useful...
24 Sep 2013 by Albert Holguin
There's a macro definition in windef.h that's name max() that resulted in this problem. The code is fine, just need a different name that won't conflict with any MS defined macros.
31 Jul 2014 by SrikantSahu
This tip can be used to know more about how dojo templated widgets can be created and used inside a portlet programmatically.
16 Jun 2015 by Sander Rossel
The fifth in a series on MEAN web development.
18 Sep 2015 by Shvetsov Evgeniy
Type tricks (above described and other)
15 Jan 2020 by Ahmed Bouchefra
In this tutorial, we’ll see by example how to create a CRUD application from scratch and step by step. We’ll see how to configure a MySQL database, enable the admin interface, and create the django views.
25 Jan 2022 by Stefan_Lang
Quote: How do we do it right 1. Post your actual question at the top, maybe even in the topic heading 2. Provide your goal and relevant detail information after that, in the body of your posting. Make sure to keep it reasonably short by...
2 Feb 2023 by Bruno van Dooren
Ways to enforce an interface contract on static methods, similar to what you would expect from static virtual methods if they'd exist in C++
1 Feb 2011 by Espen Harlinn
If you are doing text processing/parsing - you could consider usingGNU Bison[^]and flex[^]Remeber that you can use flex on its own, and it is reasonably fast :)Apart from that, I think you will find that nothing beats using pointers, and possibly reading files using ReadFile with...
10 Mar 2011 by Randy Trulson
Hey guys / gals,I have a C# solution that contains multiple projects, (A main project, and a dll project that the main project is dependant on)So the main project has a reference to the dll project in references. Fine, but when I make it into a template and load the template from the...
29 Sep 2011 by Graham Breach
First, don't use a separate source file for your template code - put it in the header file:template class buffer {public: buffer(unsigned int size) { items = new T[size]; }private: T* items;};There is no default constructor defined, so you need...
14 May 2012 by Aescleal
The zeroth thing to do with template problems...Grab the latest compiler you can.The first thing to do with any template instantiation problems...Get rid of the template. Now I know this sounds weird but if you replace hard-code everywhere the compiler might give you an idea of...
28 Jun 2012 by email2gtc
I am creating an application to recognize books by its spine. What I want to do is take picture of a book spine and match it with a database of books.I was hoping to use pattern matching and template matching for this. First i was hoping to search book by template matching using templats of...
9 Sep 2012 by Espen Harlinn
Have a look at ASP.NET Themes and Skins[^]Companies like DevExpress provide a range of pleasing themes[^] for use with their libraries and asp.net.Best regardsEspen Harlinn
22 Nov 2012 by CHill60
An almost identical question appears with some answers here http://www.telerik.com/community/forums/aspnet-ajax/grid/textbox-in-radgrid-textchanged.aspx[^]Probably the best response was to look up the help information...
13 Jul 2013 by Matthew Faithfull
The rules did change but I don't think that's the problem. I think it's just that Microsoft started applying the existing ones.It's a tricky case but I think the problem can be summarized as trying to use a protected member function pointer as a template parameter to a function that does not...
26 Nov 2013 by Stefan_Lang
As Carlo pointed out, there is no way to retrieve this information at runtime. However, you can inquire and use type information at compile time through the use of templates: the easiest way would be with the C++ 11 extensions decltype or std::result_of, or if you use GCC, it has an extension...
7 Jan 2014 by Marius Bancila
You should use typename for ModelCalc::vector_type, since this is not a type.template const typename ModelCalc::vector_type& ModelCalc::distances() const{ return m_distances;};template const typename ModelCalc::value_type& ModelCalc::length() const{ return m_length;};
11 Sep 2014 by Member 11073111
I would like to use variadic templates to help solve an issue using va-args. Basically, I want to call a singular function, pass into the function a "command" along with a variable list of arguments, then dispatch the arguments to another function.I've implemented this using tried and true...
3 May 2016 by CPallini
Actually your code compiles with g++ (I am using version 5.2.1). It gives 'undefined reference' for the th1.add call, but that's correct, since you never defined it.
8 Feb 2020 by OwenDavies
When you create an Azure Storage account to store files in a container you can set the permissions to what ever access level you want, and you can generate tokens to access the blob storage account with set periods of time. That’s what we’re going to do here today.. 0.
4 Jul 2020 by Rick York
You are overcomplicating the base class definition. Try this : using UCHAR = unsigned char; using VUCHAR = std::vector; template class ObjectTransformerBase { public: virtual T ToStructure( VUCHAR & bytes ) = 0; ...
2 Apr 2021 by Andreas Gieriet
g++ tells error: need ‘typename’ before ‘T::abc’ because ‘T’ is a dependent scope typedef T::abc local_type; You might want to turn the time back and compile with the matching C++ standard setting on your compiler. E.g. for g++, there is a...
27 Jan 2022 by Stefan_Lang
Quote: The problem was I cannot properly separate the declaration & definition of a templated symbols such as classes, structs, functions, and many more Short answer: you cannot! From the link I posted above (emphasis mine): Quote: However, when...
11 Mar 2022 by CPallini
typename does the trick, try //.. typename List::node* currentL1 = L1.first; typename List::node* currentL2 = L2.first; // ..
11 Mar 2022 by k5054
CPalini's solution is correct, but maybe in modern C++, rather than trying to puzzle out what a variable's type should be, one can use auto instead e.g.auto * currentL1 = L1.first;
4 Mar 2020 by Lee P Richardson
How to provide strongly typed, cross platform, dependency managed access to all 2,935 Azure CLI commands in C#
12 Nov 2010 by basementman
1) make your CXXXtoolbar member a public member in mainfrm.h2) include mainfrm.h in your view class cpp3) use code like this below to access your toolbar:CMainFrame *pFrame = (CMainFrame *)GetApp()->m_pMainWnd;if (pFrame) pFrame->m_wndToolBar.DoSomeFunction();
21 Dec 2010 by KingsGambit
Template declarations and definitions should be in the header file. We cannot split it between .h and .cpp files. You can check if that is the issue.
1 Feb 2011 by Yusuf
Well you need to define what you mean by "string handling" and "string manipulation". By manipulation are you talking about string copying, concatenation or what?If you have a need for string concatenation, look for this SO discussion[^], for string searching, see 'fast string search'[^]. By...
1 Feb 2011 by Emilio Garavaglia
It depends on which operations you do most often on the string.One problem can be the way std::string is implemented: just try another STL implementation, like stlport[^]They use reference counted string, thus removing lot of buffer copy.Another can be the fact you do frequent...
1 Feb 2011 by basementman
For optimal performance, use char[xx] variables and pointers and avoid making many copies of the strings. Concat in place, and split with pointers or array of pointers, nulling out the split characters in place.
11 Feb 2011 by Peter Maslin
hiive got a item template that i have created, this one is made to create a custom visual web part.the .vstemplate is defined as follows Widget...
23 May 2011 by Charles Keepax
I am slightly confused by these lines:templateAs far as I am aware this is not valid C++, it could be part of new C++0x stuff as I haven't had time to review that in detail yet. But anyway you shouldn't require to use any new features to solve this problem so I...
10 Jun 2011 by S Houghtelin
You had me confused when you said at compile time, this would mean a build directive, then you would need to create a variable or object with data binding to check for the number of compile times.If you meant to count number of times a function is accessed during run time, you have(at the...
10 Jun 2011 by Sergey Alexandrovich Kryukov
Sorry that my answer is not about C++, but my idea is so unusual and universal so it could be interesting for you.My solution is well implemented and tested; and I know for sure you can use this idea, because from in C++ you always can look at the stack and remember the calling...
19 Sep 2011 by Philippe Mori
Assuming that you want to call the function with data that look like that:char* aa[] = { "AA", "BB", "CC", "DD" };GetCodes(aa);And you want N to be automatically determined by the compiler, then you need to have a reference in the declaration and fix the parenthesis.template
26 Mar 2012 by Ewert Bergh
An easier way to do this is to import System.Windows.Controls.Primitives and use the VisualTreeHelper Extensions GetVisualDescendants or GetVisualAncestors!e.g.:protected override OnApplyTemplate(){ base.OnApplyTemplate(); Border bor = GetVisualDescendants() ...
13 Apr 2012 by Aescleal
It sounds like it would work, however without seeing the code I can't tell for sure. As you're a VC++ user perhaps download mingw (gcc for windows) and give it a whirl. If something compiles on VC++2005 or later and gcc 3.3 or later I'm usually happy it's standard code.Just to satisfy my...
2 May 2012 by Eugene Polyhaev
Fully functional groovy template scriptlets inside a docx document
13 May 2012 by Stefan_Lang
Seems to work in Visual Studio, so I can't say for sure what's the problem.However, I've found that friend declarations involving templates can be quite tricky to declare correctly. (used to be near impossible in older versions of VS) On occasion I fixed these problems by declaring a helper...
17 May 2012 by JackDingler
The line:typedef typename ATraits::Some2 Result;Should probably be:typedef typename ATraits::Result Result;Because you don't have a data member of:ClassATraits::Some2Your double declaration of ClassATraits looks a bit funky too.
17 May 2012 by Aescleal
The first thing to try when a template doesn't work is to get rid of it - manually instantiate the thing with the class(es) you want to use and see what happens. A handy hint for developing templates is always start with a non-template class then parameterise the things that you want to vary one...
28 Jun 2012 by krumia
You have done well to use histograms to identify similar images. You will have to use pattern recognition[^] to do the rest.Try separate algorithms for cropping, rotating and scaling the image. For example when a photo of a book spine is provided,1. You first rotate it such that the spine...
9 Sep 2012 by ridoy
http://www.buytemplates.net/promotion-templates/asp.net-web-templates.php[^]http://forums.asp.net/t/1306292.aspx/1[^]
18 Dec 2012 by Adam R Harris
Or you could you know ... pay for it and by extension pay the web designer that actually designed it. Either that or use it as inspiration and open up photoshop yourself and create it.Those designers work hard, just like us developers, and i think you will be hard pressed to find someone on...
31 Dec 2012 by John Bandela
This post discusses another alternative to lambda move capture.
3 Jan 2013 by Sergey Alexandrovich Kryukov
This looks like the answer: http://stackoverflow.com/questions/1782979/wpf-how-do-i-create-a-background-that-repeats-horizontally-without-scalling[^].As you want "repeat-y", not x, flip x and y in the code.Please try.—SA
12 Apr 2013 by Philippe Mori
By doing that, you are going against the design principles of STL.Maybe you can consider doing something like:template void Iterate(const T &container, F func, bool forward){ if (forward) { std::for_each(container.begin(), container.end(), func); } else ...
26 Jun 2013 by naveu2007
Hi all resolved my issue :):) thanks for the support..Just replaced the code as belowforeach (Word.ContentControl contentControl in document.ContentControls){ contentControl.Range.Text="Trial"; contentControl.Delete(false);}
25 Sep 2013 by pasztorpisti
There are many ways to implement for example containers. None of them are so clean as using templates/generics.1. One trick is using void pointers in the container implementation and later you store pointers to the items you want to store in the container. Of course you have to do ugly casts...
12 Oct 2013 by Wang Xin USTC
here the template function definitiontemplatevoid foo(T&& t){}call of fooint i = 11;foo(i);//compile and run!In the previous code ,are we binding an rvalue reference to a lvalue? why is that possible ?because we know that if we define foo as :void foo(int&&...
25 Nov 2013 by liuhaopeng
I want to get the argument types of a function pointer like this : (second line)typedef void (*fun)(int);GetParam1Type::Result
26 Dec 2013 by thatraja
Learn HTML, CSS, Javascript first. Already you know Java so better start learning JSP.For Template designing, you have two ways.0) Use CSS(styles/themes) to create templates - This way you could learn more things yourself. And easy to customize your code. It'll take more time on starting...
29 Dec 2013 by Sergey Alexandrovich Kryukov
Don't try to learn programming be "templates", this would be counterproductive. Take some book on programming and programming language of your choice and read it from the beginning to the end, trying to solve all exercises. In the meanwhile, try to read other books on theory and other languages...
4 Jun 2014 by NeonMika
So, I found a solution for my question here: http://stackoverflow.com/questions/1152128/wpf-databind-to-a-stackpanel-using-datatemplates[^]Replacing the StackPanel with a ContentPresenter and instead of DataContext using the Content property worked for me.Probably it will help someone...
15 May 2014 by ZurdoDev
I would suggest using a RadioButtonList control instead of a GridView, http://asp-net-example.blogspot.com/2008/10/radiobuttonlist-example-how-to-use.html[^]There are lots of samples online but the above link is a good one.
6 Jun 2014 by Stefan_Lang
The second definition is (almost) the same as the first. It is not a specialization at all.A template specialization requires that you instantiate all the arguments. E. g. template string TestTemplate1() {}You could also try a partial specialization, but I'm not sure about the...
18 Oct 2014 by Andreas Gieriet
Try leaving away the address-of operator while instantiating the function and pass the data in the template by reference.CheersAndi
1 Dec 2014 by ManojDhobale
Use open xml SDK for the same,Please refer below link, and Using ASP.NET MVC and the OpenXML API to Stream Excel Files[^]based on this there is a large project called EPplus, take help from therehttp://epplus.codeplex.com/[^]
12 Jan 2015 by Richard MacCutchan
See Visual C++ Express, Custom Wizard[^].
24 Apr 2016 by KarstenK
You should make your homework to learn coding. It will enhance your knowledge and skills and maybe you earn a lot of money someday.Here is a fine tutorial about How to create Linked list using C/C++ to support your efforts.;-)
21 May 2016 by Richard MacCutchan
T is just a placeholder for the real type that will be used wherever class foo appears later in your source code. see Templates (C++)[^]
21 Aug 2016 by Richard MacCutchan
The reason is because the template is not a class definition, it is a template that is used to create a class definition. It is only when you declare the actual class, which includes the declaration of the type (T) does the compiler actually create the class definition. If the friend declaration...
14 Dec 2016 by Dave Kreskowiak
Only YOU doing the research into any templates is going to answer your own question. You're the one with all the requirements. There's a ton of templates out there and only YOU know all of your requirements, likes, and dislikes. Only YOU are going to be able to say which one is "the best".
22 Jan 2019 by seventhnight
I have the following code which adds a project to the current solution from a specified template: Solution2 solution = GetSolution(); string templatePath = "..."; string genProjectPath = $"C:\\TestVSIX\\{projectName}\\"; try { ...
22 Nov 2019 by Jeremy Likness
Migrate from Medium to Hugo
15 Dec 2019 by Ahmed Bouchefra
How to send Ajax requests in Django 2 and Python 3.7 to add CRUD operations in your application and manipulate your Django models and database without having to refresh your web pages each time
15 Dec 2019 by Ahmed Bouchefra
A Django 2 CRUD example application using generic class based views using the latest Python 3.7 version
28 Feb 2020 by OwenDavies
Using Terraform to create an Azure Virtual Machine
2 Sep 2021 by CPallini
Try #include #include using namespace std; template void passarray(vector & myvec, T value) { myvec.push_back(value); } template void givevalue(vector & v){} template
13 Aug 2023 by merano99
It seems to me that templates might not be the right way for the desired functions. I would first overload only the output operator. There are several ways to do this. Instead of the function as before, a class VectorPrinter can be created that...
9 Feb 2020 by OwenDavies
Instructions detailing creation of an Azure Virtual Machine using ARM templates in PowerShell, emphasizing steps from setting up the ARM template to deploying it
16 Mar 2016 by Member 7833501
I found now a solution! Perhaps someone else can also use it.I create now a eml-File and to make it "sendable" / "ready to send" you just have the add the header "X-Unsent: 1" and if you open it now you can immediate send the email :-)here a short example:var message = new...
N 9 Apr 2024 by Pete O'Hanlon
Fun fact. Wordpress is a well-known PHP based CMS so it's obviously possible to create a CMS in PHP with support for the features you want. As well as PHP, you are going to want a database to store content and other information, and a file system...
11 Nov 2010 by vortexico
Hello, I am pretty new to the Document/View based MFC programs.I am searching for 2 days now to an answer to my problem.1 I have a toolbar derived class called CToolBarEditor2 I have derived one so I could replace one of the buttons with an CEdit3 CToolBarEditor is a member of the...
13 Nov 2010 by vortexico
Thank you for your reply.How does it come that I couldn't find a solution like this on internet?Or why does the example project not have this?Anyway, Now I know how to do it, thank you, it worked.
22 Dec 2010 by Golden Lee
Dear Sir,Follows are my codes:#pragma once// Disable warnings about long names#ifdef WIN32 #pragma warning( disable : 4786)#endif#include using namespace std;template class IMagicMap{public: _Ty m_BaseMap; virtual bool Add(_Ty&...
16 Jan 2011 by TheAteist
I created MVC project and added "Class1.cs" to it(in the same project)Class1 code:using System;using System.Collections.Generic;using System.Linq;using System.Web;using MvcApplication2.Models;namespace MvcApplication2{ public class EntityAttribute { public...
1 Feb 2011 by Pallab_GT
Hello Everybody.I am working on a performance critical project which requires a lot of char string handling and char string manipulation.Using the std::string for the mentioned purposes, is slowing down the application and I am in desperate need of something faster.What would be the...
26 Mar 2011 by jc3po
How generics can be used to sort lists easily and efficiently.