Search Results

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

Page 19/278 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • overloading friend operator<< for template class

    - by starcorn
    Hello, I have read couple of the question regarding my problem on stackoverflow now, and none of it seems to solve my problem. Or I maybe have done it wrong... The overloaded << if I make it into an inline function. But how do I make it work in my case? warning: friend declaration std::ostream& operator<<(std::ostream&, const D<classT>&)' declares a non-template function warning: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) -Wno-non-template-friend disables this warning /tmp/cc6VTWdv.o:uppgift4.cc:(.text+0x180): undefined reference to operator<<(std::basic_ostream<char, std::char_traits<char> >&, D<int> const&)' collect2: ld returned 1 exit status template <class T> T my_max(T a, T b) { if(a > b) return a; else return b; } template <class classT> class D { public: D(classT in) : d(in) {}; bool operator>(const D& rhs) const; classT operator=(const D<classT>& rhs); friend ostream& operator<< (ostream & os, const D<classT>& rhs); private: classT d; }; int main() { int i1 = 1; int i2 = 2; D<int> d1(i1); D<int> d2(i2); cout << my_max(d1,d2) << endl; return 0; } template <class classT> ostream& operator<<(ostream &os, const D<classT>& rhs) { os << rhs.d; return os; }

    Read the article

  • Setting a breakpoint in a T4 template

    - by Dave Swersky
    I'm trying to debug the execution of a T4 template in Visual Studio 2008. All the information I'm finding on debugging T4 templates in Visual Studio 2008 say that you can set a breakpoint (red dot) in the template as if it were a regular code file. I have the Clarius T4 code highlighter installed, so my T4 template is colored, but I can't set a breakpoint. When I click in the margin nothing happens. I've tried Debugger.Break(), and it launches a new instance of VS.NET, but it can't load the code from my template. I get a dialog that says "There is no source code available for the current location." This happens if I have the same project loaded in the another instance of if I spin up a new instance. What gives?

    Read the article

  • calling template function without <>; type inference

    - by Oops
    Hi, if I have a function template with typename T, where the compiler can set the type by itself, I do not have to write the type explicitely when I call the function like: template < typename T > T min( T v1, T v2 ) { return ( v1 < v2 ) ? v1: v2; } int i1 = 1, i2 = 2; int i3 = min( i1, i2 ); //no explicit <type> but if I have a function template with two different typenames like... template < typename TOut, typename TIn > TOut round( TIn v ) { return (TOut)( v + 0.5 ); } double d = 1.54; int i = round<int>(d); //explicit <int> Is it true that I have to specify at least 1 typename, always? I assume the reason is because C++ can not distinguish functions between different return types, true? but if I use a void function and handover a reference, again I must not explicitely specify the return typename: template < typename TOut, typename TIn > void round( TOut & vret, TIn vin ) { vret = (TOut)(vin + 0.5); } double d = 1.54; int i; round(i, d); //no explicit <int> should the conclusion be to avoid functions with return and more prefer void functions that return via a reference when writing templates? Or is there a possibility to avoid explicitely writing the return type? something like "type inference" for templates... is "type inference" possible in C++0x? I hope I was not too unclear. many thanks in advance Oops

    Read the article

  • Grails pattern to reuse template on error

    - by bsreekanth
    Hello, I have a gsp template, where the data for create view is passed through the controller. def create = { def bookInstance = new Book() bookInstance .properties = params def map = getDefaultValues() render(template: "create", model: [bookInstance : bookInstance , title: map.title, somelist: somelist ....]) the gsp template <g:select optionKey="id" from="${somelist}" name="somelist.id" value="${bookInstance ?.somelist?.id}" noSelection="['null': '']"></g:select> now, in the save method, if there is an error, it returns currently populated and validated instance (default scaffold implementation) render(template: "create", model: [bookInstance : bookInstance ]) But the fields in the gsp (error page rendered from save action) is empty. I could see the reason as it looks the value in "${somelist}" , but it is not used in save method. Do i just need to check for null in the gsp and use whichever map is available, or any better method (passing all the map in the save method is not an option) .. thanks in advance..

    Read the article

  • how to templatize partial template specializations?

    - by Kyle
    I'm not even sure what title to give this question; hopefully the code will demonstrate what I'm trying to do: #include <string> #include <list> using namespace std; template<typename A> class Alpha { public: A m_alpha_a; }; template<typename B> class Bravo { public: B m_bravo_b; }; template<> class Alpha<string> { public: string m_alpha_string; }; template<typename B> template<> class Alpha<Bravo<B> > { public: Bravo<B> m_bravo_class; // Line A }; int main() { Alpha<int> alpha_int; alpha_int.m_alpha_a= 4; Alpha<string> alpha_string; alpha_string.m_alpha_string = "hi"; Alpha<Bravo<int> > alpha_bravo_int; alpha_bravo_int.m_bravo_class.m_bravo_b = 9; }; I want to write a specialization for Alpha<A> when A is of any type Bravo<B>, but the compiler says invalid explicit specialization before ‘’ token enclosing class templates are not explicitly specialized (Referring to // Line A.) What's the correct syntax to do what I want?

    Read the article

  • Is it possible to use JavaScript inside handlebars.js template

    - by Gleeb
    The description says it all. How to put a JavaScript script inside handlebars template. I want to make a dynamic Paypal button for my website. <script type="text/x-mustache-template" id="product-item-thumbnail-template"> <h2>{{title}}</h2> <p>{{message}}</p> <p><a class="btn" href="#">View details &raquo;</a></p> <p><script src="resources/js-frameworks/[email protected]" data-button="buynow" data-name="My product" data-amount="1.00"></script></p> </script> But this produces an error because of the tag. it closes the template script and not the paypal script Thanks

    Read the article

  • Store variables during loop and use in it another template

    - by krisvandenbergh
    Is there a way to store a variable/param during a for-each loop in a sort of array, and use it in another template, namely <xsl:template match="Foundation.Core.Classifier.feature">. All the classname values that appear during the for-each should be stored. How would you implement that in XSLT? Here's my current code. <xsl:for-each select="Foundation.Core.Class"> <xsl:for-each select="Foundation.Core.ModelElement.name"> <xsl:param name="classname"> <xsl:value-of select="Foundation.Core.ModelElement.name"/> </xsl:param> </xsl:for-each> <xsl:apply-templates select="Foundation.Core.Classifier.feature" /> </xsl:for-each> Here's the template in which the classname parameters should be used. <xsl:template match="Foundation.Core.Classifier.feature"> <xsl:for-each select="Foundation.Core.Attribute"> <owl:DatatypeProperty rdf:ID="{Foundation.Core.ModelElement.name}"> <rdfs:domain rdf:resource="$classname" /> </owl:DatatypeProperty> </xsl:for-each> </xsl:template> The input file can be found at http://krisvandenbergh.be/uml_pricing.xml

    Read the article

  • C++ adding friend to a template class in order to typecast

    - by user1835359
    I'm currently reading "Effective C++" and there is a chapter that contains code similiar to this: template <typename T> class Num { public: Num(int n) { ... } }; template <typename T> Num<T> operator*(const Num<T>& lhs, const Num<T>& rhs) { ... } Num<int> n = 5 * Num<int>(10); The book says that this won't work (and indeed it doesn't) because you can't expect the compiler to use implicit typecasting to specialize a template. As a soluting it is suggested to use the "friend" syntax to define the function inside the class. //It works template <typename T> class Num { public: Num(int n) { ... } friend Num operator*(const Num& lhs, const Num& rhs) { ... } }; Num<int> n = 5 * Num<int>(10); And the book suggests to use this friend-declaration thing whenever I need implicit conversion to a template class type. And it all seems to make sense. But why can't I get the same example working with a common function, not an operator? template <typename T> class Num { public: Num(int n) { ... } friend void doFoo(const Num& lhs) { ... } }; doFoo(5); This time the compiler complaints that he can't find any 'doFoo' at all. And if i declare the doFoo outside the class, i get the reasonable mismatched types error. Seems like the "friend ..." part is just being ignored. So is there a problem with my understanding? What is the difference between a function and an operator in this case?

    Read the article

  • Actually XSLT Lookup (Store variables during loop and use in it another template)

    - by krisvandenbergh
    Is there a way to store a variable/param during a for-each loop in a sort of array, and use it in another template, namely <xsl:template match="Foundation.Core.Classifier.feature">. All the classname values that appear during the for-each should be stored. How would you implement that in XSLT? Here's my current code. <xsl:for-each select="Foundation.Core.Class"> <xsl:for-each select="Foundation.Core.ModelElement.name"> <xsl:param name="classname"> <xsl:value-of select="Foundation.Core.ModelElement.name"/> </xsl:param> </xsl:for-each> <xsl:apply-templates select="Foundation.Core.Classifier.feature" /> </xsl:for-each> Here's the template in which the classname parameters should be used. <xsl:template match="Foundation.Core.Classifier.feature"> <xsl:for-each select="Foundation.Core.Attribute"> <owl:DatatypeProperty rdf:ID="{Foundation.Core.ModelElement.name}"> <rdfs:domain rdf:resource="$classname" /> </owl:DatatypeProperty> </xsl:for-each> </xsl:template> The input file can be found at http://krisvandenbergh.be/uml_pricing.xml

    Read the article

  • Select a data template by item type programatically in WPF

    - by Michael Stoll
    Hi all, unfortunately the WPF ToolbarTray does not support binding to a collection of ToolbarViewModels (Correct me, if I'm wrong). Thus I want to create the Toolbars programmatically. So there are two tasks, which I don't know how to do: Select the data template based on the item type. Instantiate the data template as toolbar Both should do the same as WPF does, when we use ItemsControl with an enumerable content and empty template. I used reflector to anaylse what WPF does. Task 1 is done by FrameworkElement.FindTemplateResourceInternal, but this is internal, and I couldn't find any public methods to acomplish the task. Of course one could enumerate all resources and match the data template data type property, but this seems sub-optimal. Who know's how to acomplish these tasks?

    Read the article

  • problem with MySQL installation : template configuration file cannot be found

    - by user35389
    Trying to install MySQL onto the Windows XP machine. While going through the installation steps (in the "MySQL Server Instance Config. Wizard"), I get to a point where it the window reads: MySQL Server Instance Configuration (bold header) Choose the configuration for the server instance. Ready to execute... o Prepare configuration o Write configuration file o Start service o Apply security settings (this line is greyed out) Please press [Execute] to start the configuration. [ Back ] [ Execute ] [ Cancel ] So I press execute, and then a red X appears in the second step: Write configuration file and at the bottom, where it originally said: Please press [Execute] to start the configuration. It now says: The template configuration file cannot be found at C:\Program Files\MySQL\MySQL Server 5.0\bin\my-template.cnf I'm unsure what it means, but I canceled the config wizard and looked in the directory that had been created (C:\Program Files\MySQL\MySQL Server 5.0). There are some configuration settings files, and there are 4 folders: bin data Docs share

    Read the article

  • "Ambiguous template specialization" problem

    - by Setien
    I'm currently porting a heap of code that has previously only been compiled with Visual Studio 2008. In this code, there's an arrangement like this: template <typename T> T convert( const char * s ) { // slow catch-all std::istringstream is( s ); T ret; is >> ret; return ret; } template <> inline int convert<int>( const char * s ) { return (int)atoi( s ); } Generally, there are a lot of specializations of the templated function with different return types that are invoked like this: int i = convert<int>( szInt ); The problem is, that these template specializations result in "Ambiguous template specialization". If it was something besides the return type that differentiated these function specializations, I could obviously just use overloads, but that's not an option. How do I solve this without having to change all the places the convert functions are called?

    Read the article

  • Re render template when submit a form

    - by Agusti-N
    Hi, i've this problem: I've a view that render a template and then retrive to the user the rendered template. Yesterday i want to add a form. The problem is when i submit this form to the same url that the view render the template, i have to re render the template with previusly data and then show the errors (if they are) in the form with the new renderd data, so i have to re render all the time the previusly information. I've view a lot of examples, but ALL examples have the form in an externar html(separated) How can avoid this ?

    Read the article

  • Silverlight: TextBlock has no Template property?

    - by Shnitzel
    Guys, I want to customize the look of a TextBlock. (I want a rounded rectangle border around it). But I'd like to be able to set it's template via the app.xaml But I see that TextBlock doesn't have a Template property. I'd use Label (which does have a Template property) but I guess silverlight doesn't support a Label control. So what can I use to do this? Thanks in advance.

    Read the article

  • Smarty: including a template file from the same directory

    - by Robert Munteanu
    I have a Smarty template located in a directory under templates_dir: templates/some/dir/template.tpl . In the same directory, I have a sub-template: templates/some/dir/_component.tpl . I can't include the sub-component using an unqualified include, since apparently it looks it up under the templates_dir: {include file='_component.tpl'} How can I tell Smarty to read the file from the same directory, as opposed to the templates root ? I do not want to specify absolute paths, since it will cause problems when changing directory structures.

    Read the article

  • Why does /**[newline] not always insert the Javadoc template including @param and @return in Eclipse

    - by Bas van den Broek
    I'm documenting code in Eclipse and have been using the /** followed by Enter alot to insert the Javadoc template. However this does not always work for some reason, it will create the template for writing comments but it won't automatically insert the @param and @return text. If I copy the exact same method to another class it will insert the full template. It would be a big help if anyone could tell me why it won't do this in some situations.

    Read the article

  • Template engine recommendations

    - by alex
    I'm looking for a template engine. Requirements: Runs on a JVM. Java is good; Jython, JRuby and the like, too... Can be used outside of servlets (unlike JSP) Is flexible wrt. to where the templates are stored (JSP and a lot of people require the templates to be stored in the FS). It should provide a template loading interface which one can implement or something like that Easy inclusion of parameterized templates- I really like JSP's tag fragments Good docs, nice code, etc., the usual suspects I've looked at JSP- it's nearly perfect except for the servlet and filesystem coupling, Stringtemplate- I love the template syntax, but it fails on the filesystem coupling, the documentation is lacking and template groups and stuff are confusing, GXP, TAL, etc. Ideas, thoughts? Alex

    Read the article

  • magento free template with left side menu

    - by Hima
    Hai I want to create a magento web site, which have left side menus (product category - products). Not in the top. I am wanted to download free template. Does any one help me to get the free template having left side menu. Or any good URL to download this template

    Read the article

  • Error 500 on template.render() with jinja2

    - by Asperitas
    I am working on playing with some Python to create a webapp. At first I put the HTML in a string, using %s to fill certain elements. That all worked perfectly. Now I want to put the HTML in a template, so I followed this tutorial. My code looks like this (I deleted irrelevant code for this error): import codecs import cgi import os import jinja2 jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__)))) class Rot13Handler(webapp2.RequestHandler): def get(self): template = jinja_environment.get_template('rot13.html') self.response.out.write(template.render({'text': ''})) When I replace just template.render({'text': ''}) a random string, the program works fine. I did add the latest jinja2 library to my app.yaml, and naturally my rot13.html does exist with the {{ text }} added. So could anyone please help me in the right direction? I don't know why it's going wrong.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >