Search Results

Search found 6937 results on 278 pages for 'template'.

Page 13/278 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Template Syntax in C++

    - by Crystal
    I don't understand templates really and was trying to run a simple find the minimum for ints, doubles, chars. First question, why is template<typename T> sometimes used, and other times template<>? Second question, I do not know what I am doing wrong with the following code below: #include <iostream> template <typename T> T minimum(T arg1, T arg2) { return arg1 < arg2 ? arg1 : arg2; } template <typename T> // first I tried template <> instd of above, but wasn't sure the difference T minimum<const char *>(const char *arg1, const char *arg2) { return strcmp(arg1, arg2) ? arg2 : arg1; } int main() { std::cout << minimum<int>(4, 2) << '\n'; std::cout << minimum<double>(2.2, -56.7) << '\n'; std::cout << minimum(2.2, 2) << '\n'; } Compile Errors: error C2768: 'minimum' : illegal use of explicit template arguments error C2783: 'T minimum(const char *,const char *)' : could not deduce template argument for 'T' : see declaration of 'minimum' : error C2782: 'T minimum(T,T)' : template parameter 'T' is ambiguous : see declaration of 'minimum' Third, in getting familiar with separating .h and .cpp files, if I wanted this minimum() function to be a static function of my class, but it was the only function in that class, would I have to have a template class as well? I originally tried doing it that way instead of having it all in one file and I got some compile errors as well that I can't remember right now and was unsure how I would do that. Thanks!

    Read the article

  • ReSharper C# Live Template for Dependency Property and Property Change Routed Event Boilerplate Code

    - by Bart Read
    I don't know about you but it took me about 5 seconds to get royally fed up of typing the boilerplate code necessary for creating WPF (and Silverlight) dependency properties and, if you want them, their associated property change routed events. Being a ReSharper user, I wondered if there was any live template for doing this. It turns out there's nothing built in, but there are many examples of templates for creating dependency properties out there on the web, such as this excellent one from Roy...(read more)

    Read the article

  • Refactor: Sequential Coupling => Template Method

    Another colleague brought me present today - the blog post. Thank you. You were right!We will do some refactoring which will lead us from Anti-Pattern to Pattern. From Sequential Coupling to Template Method. And as I see it could be very common way to refactor bad code that represents mentioned anti

    Read the article

  • Script + template to generate static web site?

    - by user702
    After giving it more thought, I don't actually need a PHP-based CMS for a small, static web site. Does someone know of a good solution that can run on Windows that would take basic HTML pages and JPG pictures, combine those with a template, and generate a static site ready to be FTPed to an web server? Thank you. Edit: For those looking for the same information, here's some well-known tools to create a static site: http://get-simple.info/ http://gpeasy.com/How_Easy http://textpattern.com/features http://nanoc.stoneship.org/ http://www.movabletype.com/

    Read the article

  • Is there a way to use template specialization to separate new from new[]?

    - by Marlon
    I have an auto pointer class and in the constructor I am passing in a pointer. I want to be able to separate new from new[] in the constructor so that I can properly call delete or delete[] in the destructor. Can this be done through template specialization? I don't want to have to pass in a boolean in the constructor. template <typename T> class MyAutoPtr { public: MyAutoPtr(T* aPtr); }; // in use: MyAutoPtr<int> ptr(new int); MyAutoPtr<int> ptr2(new int[10]);

    Read the article

  • how do I use html block snippets with dynamic content inside a django template that extends another

    - by stackoverflowusername
    Hi. Can someone please help me figure out a way to achieve the following (see snippets below) in Django templates? I know that you cannot use more than one extends, but I am new to django and I do not know the proper syntax for something like this. I want to be able to do this so that I can use my nested div layout for css reasons without having to type it like that each time and risking a typo. In words, I want to be able to have a page template extend my base.html file and then use html snippets of dynamic template content (i.e. template for loops or other template logic devices, not just a context variable I set from my view controller). ------------------------------------------------------------ base.html ------------------------------------------------------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>{% block title %}Title{% endblock %}</title> </head> <body> <div class="wrapper"> <div class="header"> This is the common header </div> <div class="nav"> This is the common nav </div> {% if messages %} <div class="messages"> <ul> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> </div> {% endif %} <div class="content"> {% block content %}Page Content{% endblock %} </div> <div class="footer"> This is the common footer </div> </div> </body> </html> ------------------------------------------------------------ columnlayout2.html ------------------------------------------------------------ <div class="twocol container2"> <div class="container1"> <div class="col1"> {% block twocol_col1 %}{% endblock %} </div> <div class="col2"> {% block twocol_col2 %}{% endblock %} </div> </div> </div> ------------------------------------------------------------ columnlayout3.html ------------------------------------------------------------ <div class="threecol container3"> <div class="container2"> <div class="container1"> <div class="col1"> {% block threecol_col1 %}{% endblock %} </div> <div class="col2"> {% block threecol_col2 %}{% endblock %} </div> <div class="col3"> {% block threecol_col3 %}{% endblock %} </div> </div> </div> </div> ------------------------------------------------------------ page.html ------------------------------------------------------------ {% extends "base.html" %} {% block content %} {% extends "columnlayout2.html" %} {% block twocol_col1 %}twocolumn column 1{% endblock %} {% block twocol_col2 %}twocolumn column 2{% endblock %} {% extends "columnlayout3.html" %} {% block threecol_col1 %}threecol column 1{% endblock %} {% block threecol_col2 %}threecol column 2{% endblock %} {% block threecol_col3 %}threecol column 3{% endblock %} {% endblock %} ------------------------------------------------------------ page.html output ------------------------------------------------------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Title</title> </head> <body> <div class="wrapper"> <div class="header"> This is the common header </div> <div class="nav"> This is the common nav </div> <div class="content"> <div class="twocol container2"> <div class="container1"> <div class="col1"> twocolumn column 1 </div> <div class="col2"> twocolumn column 2 </div> </div> </div> <div class="threecol container3"> <div class="container2"> <div class="container1"> <div class="col1"> threecol column 1 </div> <div class="col2"> threecol column 2 </div> <div class="col3"> threecol column 3 </div> </div> </div> </div> </div> <div class="footer"> This is the common footer </div> </div> </body> </html>

    Read the article

  • boost::enable_if class template method

    - by aaa
    I got class with template methods that looks at this: struct undefined {}; template<typename T> struct is_undefined : mpl::false_ {}; template<> struct is_undefined<undefined> : mpl::true_ {}; template<class C> struct foo { template<class F, class V> typename boost::disable_if<is_undefined<C> >::type apply(const F &f, const V &variables) { } template<class F, class V> typename boost::enable_if<is_undefined<C> >::type apply(const F &f, const V &variables) { } }; apparently, both templates are instantiated, resulting in compile time error. is instantiation of template methods different from instantiation of free functions? I have fixed this differently, but I would like to know what is up. Thank you

    Read the article

  • Mapping integers to types using C++ template fails in a specific case

    - by Shailesh Kumar
    I am attempting to compile the following template based code in VC++ 2005. #include <iostream> using namespace std; /* * T is a template which maps an integer to a specific type. * The mapping happens through partial template specialization. * In the following T<1> is mapped to char, T<2> is mapped to long * and T<3> is mapped to float using partial template specializations */ template <int x> struct T { public: }; template<> struct T<1> { public: typedef char xType; }; template<> struct T<2> { public: typedef long xType; }; template<> struct T<3> { public: typedef float xType; }; // We can easily access the specific xType for a specific T<N> typedef T<3>::xType x3Type; /*! * In the following we are attempting to use T<N> inside another * template class T2<R> */ template<int r> struct T2 { //We can map T<r> to some other type T3 typedef T<r> T3; // The following line fails typedef T3::xType xType; }; int main() { T<1>::xType a1; cout << typeid(a1).name() << endl; T<2>::xType a2; cout << typeid(a2).name() << endl; T<3>::xType a3; cout << typeid(a3).name() << endl; return 0; } There is a particular line in the code which doesn't compile: typedef T3::xType xType; If I remove this line, compilation goes fine and the result is: char long float If I retain this line, compilation errors are observed. main.cpp(53) : warning C4346: 'T<x>::xType' : dependent name is not a type prefix with 'typename' to indicate a type main.cpp(54) : see reference to class template instantiation 'T2<r>' being compiled main.cpp(53) : error C2146: syntax error : missing ';' before identifier 'xType' main.cpp(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int I am not able to figure out how to make sure that T::xType can be treated as a type inside the T2 template. Any help is highly appreciated.

    Read the article

  • Default template arguments for function templates

    - by Arman
    Why are default template arguments only allowed on class templates? Why can't we define a default type in a member function template? For example: struct mycclass { template<class T=int> void mymember(T* vec) { // ... } }; Instead, C++ forces that default template arguments are only allowed on a class template.

    Read the article

  • Problem filling Django template in googleappengine Loader

    - by googleappenginenewbie
    I am trying to test a googleapengine project locally, but am getting errors loading templates: My settings.py contains TEMPLATE_LOADERS with Loader wrappers: e.g. django.template.loaders.filesystem.Loader but there is no Loader wrapper class in the bundled filesystem.py file within xx/google_appengine/lib/django/django/template/loaders/ so I'm getting this error: Exception Type: ImproperlyConfigured Exception Value: Module "django.template.loaders.filesystem" does not define a "Loader" callable template source loader Exception Location: in xxxx/google_appengine/lib/django/django/template/loader.py in find_template_source, line 60

    Read the article

  • Syntax Error with John Resig's Micro Templating after changing template tags <# {% {{ etc..

    - by optician
    I'm having a bit of trouble with John Resig's Micro templating. Can anyone help me with why it isn't working? This is the template <script type="text/html" id="row_tmpl"> test content {%=id%} {%=name%} </script> And the modified section of the engine str .replace(/[\r\t\n]/g, " ") .split("{%").join("\t") .replace(/((^|%>)[^\t]*)'/g, "$1\r") .replace(/\t=(.*?)%>/g, "',$1,'") .split("\t").join("');") .split("%}").join("p.push('") .split("\r").join("\\'") + "');}return p.join('');"); and the javascript var dataObject = { "id": "27", "name": "some more content" }; var html = tmpl("row_tmpl", dataObject); and the result, as you can see =id and =name seem to be in the wrong place? Apart from changing the template syntax blocks from <% % to {% %} I haven't changed anything. This is from Firefox. Error: syntax error Line: 30, Column: 89 Source Code: var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push(' test content ');=idp.push(' ');=namep.push(' ');}return p.join('');

    Read the article

  • Entity Framework POCO Template for .NET 3.5

    If you are using Visual Studio 2010 and targeting .NET 3.5, you can still use the new T4 POCO template generation. I discovered this accidentally. (How else?) When you attempt to add a new code generation item from the model, there will be no templates available:   But if you click on Online Templates, there is an ADO.NET POCO Generator created by Microsoft: And it does the job as expected! Nice!...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • The joomla 'create a template' tutorial

    - by ryan
    Hello all, Ive recently downloaded joomla using an instant download option, and now im looking to create my own templates, so i went to http://www.siteground.com/tutorials/joomla15/joomla_create_template.htm and Im trying to follow the tuturial but ive failed at the first hurdle... where it says "First, open the "templates" directory in your Joomla installation. Then create a subfolder in it named "tutorial_template". All the files of your template will reside in it." The problem is I have no clue how to do this, where is the directory to start with?? the only thing I know how to get up is the administrators screen, in which I have to choose one of the stock templates, which would be great if I didnt care about my own designs...but obviously im looking to have my own html and css coding used instead. How do I find where the folders are and how do I open them? Im sorry if its a bit of a dumb question but im so confused..so early on. Thanks in advance. Ryan

    Read the article

  • Binding a select in a client template

    I recently got a question on one of my client template posts asking me how to bind a select tags value to data in client templates. I was surprised not to find anything on the web addressing the problem, so I thought Id write a short post about it. It really is very simple once you know where to look. You just need to bind the value property of the select tag, like this: <select sys:value="{binding color}"> If you do it from markup like here, you just need to use the sys: prefix....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Binding a select in a client template

    I recently got a question on one of my client template posts asking me how to bind a select tags value to data in client templates. I was surprised not to find anything on the web addressing the problem, so I thought Id write a short post about it. It really is very simple once you know where to look. You just need to bind the value property of the select tag, like this: <select sys:value="{binding color}"> If you do it from markup like here, you just need to use the sys: prefix....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Use a template to get alternate behaviour?

    - by Serge
    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 const id){ MCard card = *this; this->id = id; this->onChange.fire(EventArgs<MCard&, MCard&>(*this, card)); return this->id; } myCard.sId(9); myCard.sId<true>(8); As you can see, my goal is to be able to have an alternative behaviour for sId. I know I could use a second parameter to the function and use a if, but this feels more fun (imo) and might prevent branch prediction (I'm no expert in that field). So, is it a valid practice, and/or is there a better approach?

    Read the article

  • SharePoint 2010 Console App, Project Template

    - by Sahil Malik
    SharePoint 2010 Training: more information I wish I had done this earlier, I have wasted so much time over the past 2 years doing the following. Create a console app Add reference to Microsoft.SharePoint.dll Hit F5, curse because I forgot to set the framework to .NET 3.5 Right click properties, change framework to .NET 3.5 Hit F5, curse again because I get a FileNotFoundException, because I forgot to make it a x64 app. Finally on my way, 2 minutes later – which has added to atleast 2 hours over the last year.   Well, no more! Presenting, the SharePoint console app project template. What? You want it too? Okay here it is. Read full article ....

    Read the article

  • Crafting an effective php/web programmer job post template [closed]

    - by Tchalvak
    I am looking to create a job post to get a satisfactory assistant programmer / templater. Specifically, a php & web programmer. I am, however, afraid of forgetting important things. So, are there resources you can suggest for templates for things to ask and things to tell in a job post for a programmer? Surprisingly, I wasn't able to find similar questions on this site, so there may be duplicate questions out there that I could use but just didn't find. Right now I know that my -requirements- are so generic that they're going to get me in trouble with a spam of applications. e.g. the candidate must know php, must be able to seperate php from html. So I'm looking for criteria that are must-haves, must-mentions, or a general template to try to avoid a "lemon". I also started a gist to work on a job post, comments/edits would be excellent: https://gist.github.com/2906808

    Read the article

  • Can you recommend a good test plan template?

    - by Ethel Evans
    Can you recommend a good test plan template for an agile testing team? I know there are templates for testing on the web and have already looked at some found by search engines, but I could really use something lightweight and something that has already been tried by skilled testers and is known to work well. Many templates I've seen give me the feeling that writing test documents is expected to be a third of the work that those testers are doing, but my team really prefers to use less documentation and more actual test writing. We use a wiki for documentation, so an approach that lends itself to living documents would be great. My hope is that using a more structured approach to test planning will increase the usefulness of my test plan while reducing the effort to create it by allowing me to think about the tests, and not the format and structure of the plan. My workplace does not have something already on hand, so whatever I start doing might be adopted by the company.

    Read the article

  • Android / IPhone / Desktop C++ Game Template

    - by OriginalDaemon
    I was wondering if anyone has come across any articles detailing how to set up a basic game in C++ for use in Android / IPhone / Desktop applications. My thoughts just now are that I would like to make my game as a library and have a different project for each device which just interfaces with this library. You know the kind of thing, bootstrap the program, call some library initialize, load and run routines and occasionally pass some information to the library like input. I was hoping someone would have made a template for this kind of thing but I just had no luck finding one. It seems to me that it's the kind of thing you really only have to do once, so I was hoping someone would have done it for me already.

    Read the article

  • Elegant way for a recursive C++ template to do something different with the leaf class?

    - by Costas
    I have a C++ class template that makes an Array of pointers. This also gets typedefed to make Arrays of Arrays and so on: typedef Array<Elem> ElemArray; typedef Array<ElemArray> ElemArrayArray; typedef Array<ElemArrayArray> ElemArrayArrayArray; I would like to be able to set one leaf node from another by copying the pointer so they both refer to the same Elem. But I also want to be able to set one Array (or Array of Arrays etc) from another. In this case I don't want to copy the pointers, I want to keep the arrays seperate and descend into each one until I get to the leaf node, at where I finally copy the pointers. I have code that does this (below). When you set something in an Array it calls a CopyIn method to do the copying. But because this is templated it also has to call the CopyIn method on the leaf class, which means I have to add a dummy method to every leaf class that just returns false. I have also tried adding a flag to the template to tell it whether it contains Arrays or not, and so whether to call the CopyIn method. This works fine - the CopyIn method of the leaf nodes never gets called, but it still has to be there for the compile to work! Is there a better way to do this? #include <stdio.h> class Elem { public: Elem(int v) : mI(v) {} void Print() { printf("%d\n",mI); } bool CopyIn(Elem *v) { return false; } int mI; }; template < typename T > class Array { public: Array(int size) : mB(0), mN(size) { mB = new T* [size]; for (int i=0; i<mN; i++) mB[i] = new T(mN); } ~Array() { for (int i=0; i<mN; i++) delete mB[i]; delete [] mB; } T* Get(int i) { return mB[i]; } void Set(int i, T* v) { if (! mB[i]->CopyIn(v) ) { // its not an array, so copy the pointer mB[i] = v; } } bool CopyIn(Array<T>* v) { for (int i=0; i<mN; i++) { if (v && i < v->mN ) { if ( ! mB[i]->CopyIn( v->mB[i] )) { // its not an array, so copy the pointer mB[i] = v->mB[i]; } } else { mB[i] = 0; } } return true; // we did the copy, no need to copy pointer } void Print() { for (int i=0; i<mN; i++) { printf("[%d] ",i); mB[i]->Print(); } } private: T **mB; int mN; }; typedef Array<Elem> ElemArray; typedef Array<ElemArray> ElemArrayArray; typedef Array<ElemArrayArray> ElemArrayArrayArray; int main () { ElemArrayArrayArray* a = new ElemArrayArrayArray(2); ElemArrayArrayArray* b = new ElemArrayArrayArray(3); // In this case I need to copy the pointer to the Elem into the ElemArrayArray a->Get(0)->Get(0)->Set(0, b->Get(0)->Get(0)->Get(0)); // in this case I need go down through a and b until I get the to Elems // so I can copy the pointers a->Set(1,b->Get(2)); b->Get(0)->Get(0)->Get(0)->mI = 42; // this will also set a[0,0,0] b->Get(2)->Get(1)->Get(1)->mI = 96; // this will also set a[1,1,1] // should be 42,2, 2,2, 3,3, 3,96 a->Print(); }

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >