Search Results

Search found 3595 results on 144 pages for 'templates deduction'.

Page 23/144 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • Template function as a template argument

    - by Kos
    I've just got confused how to implement something in a generic way in C++. It's a bit convoluted, so let me explain step by step. Consider such code: void a(int) { // do something } void b(int) { // something else } void function1() { a(123); a(456); } void function2() { b(123); b(456); } void test() { function1(); function2(); } It's easily noticable that function1 and function2 do the same, with the only different part being the internal function. Therefore, I want to make function generic to avoid code redundancy. I can do it using function pointers or templates. Let me choose the latter for now. My thinking is that it's better since the compiler will surely be able to inline the functions - am I correct? Can compilers still inline the calls if they are made via function pointers? This is a side-question. OK, back to the original point... A solution with templates: void a(int) { // do something } void b(int) { // something else } template<void (*param)(int) > void function() { param(123); param(456); } void test() { function<a>(); function<b>(); } All OK. But I'm running into a problem: Can I still do that if a and b are generics themselves? template<typename T> void a(T t) { // do something } template<typename T> void b(T t) { // something else } template< ...param... > // ??? void function() { param<SomeType>(someobj); param<AnotherType>(someotherobj); } void test() { function<a>(); function<b>(); } I know that a template parameter can be one of: a type, a template type, a value of a type. None of those seems to cover my situation. My main question is hence: How do I solve that, i.e. define function() in the last example? (Yes, function pointers seem to be a workaround in this exact case - provided they can also be inlined - but I'm looking for a general solution for this class of problems).

    Read the article

  • How to represent "{{" in a django template?

    - by rxin
    I'm trying to output in bibtex format in Django and the template looks like this: @{{ pubentry.type }{, author = {{% for author in pubentry.authors.all %}{{ author.first_name }} {{ author.middle_name }} {{ author.last_name }}{% if not forloop.last %} and {% endif %} {% endfor %}}, title = {{{ pubentry.title }}}, journal = {{{ pubentry.journal }}} } The problem is with the "{{{" or "{{%". One way to go around the problem is to add a space after the first "{", but that kind of tamper the format. What's the right way to escape { in Django templates?

    Read the article

  • Is there a replacement for Paste.Template?

    - by Jorge Vargas
    I have grown tired of all the little issues with paste template, it's horrible to maintain the templates, it has no way of updating an old project and it's very hard to test. I'm wondering if someone knows of an alternative for quickstart generators as they have proven to be useful.

    Read the article

  • Changing output of Forms with Struts+Freemarker

    - by Chris
    I'm working on a Website with Struts2 and Freemarker. Whenever I add form tags such as: <@s.form action="foo" <@s.combobox (...)/ It generates a bunch of html/css/javascript that I don't need. Is there any way I can specify that no extra elements should be generated or do I really need to go into Freemarker.jar and edit the templates to my liking?

    Read the article

  • Cant get the child dir in django hosting (alwaysdata.com) .

    - by zjm1126
    this is my file : mysite templates homepage.html accounts a.html login_view.html i can get the homepage.html and accounts\a.html on 127.0.0.1:8000 but in http://zjm1126.alwaysdata.net , i can only get the homepage.html ,and cant get the account\a.html , this is my code : return render_to_response('accounts/login_view.html') and the accounts/login_view.html is : {% include "accounts\a.html" %} what can i do , thanks ,

    Read the article

  • Alias for a C++ template?

    - by porgarmingduod
    typedef boost::interprocess::managed_shared_memory::segment_manager segment_manager_t; // Works fine, segment_manager is a class typedef boost::interprocess::adaptive_pool allocator_t; // Can't do this, adaptive_pool is a template The idea is that if I want to switch between boost interprocess' several different options for shared memory and allocators, I just modify the typedefs. Unfortunately the allocators are templates, so I can't typedef the allocator I want to use. Is there a way to achieve an alias to a template in C++? (Except for the obvious #define ALLOCATOR_T boost::interprocess::adaptive_pool)

    Read the article

  • Class Template Instantiation: any way round this circular reference?

    - by TimYorke34
    I have two classes that I'm using to represent some hardware: A Button and an InputPin class which represent a button that will change the value of an IC's input pin when it's pressed down. A simple example of them is: template <int pinNumber> class InputPin { static bool IsHigh() { return ( (*portAddress) & (1<<pinNumber) ); } }; template <typename InputPin> class Button { static bool IsPressed() { return !InputPin::IsHigh(); } }; This works beautifully and by using class templates, the condition below will compile as tightly as if I'd handwritten it in assembly (a single instruction). Button < InputPin<1> > powerButton; if (powerButton.IsPressed()) ........; However, I am extending it to deal with interrupts and have got a problem with circular references. Compared to the original InputPin, a new InputPinIRQ class has an extra static member function that will be called automatically by the hardware when the pin value changes. I'd like it to be able to notify the Button class of this, so that the Button class can then notify the main application that it has been pressed/released. I am currently doing this with function pointers to callbacks. In order for the callback code to be inlined by the compiler, I need to pass the function pointers as template parameters. So now, both of the new classes have an extra template parameter that is a pointer to a callback function. Unfortunately this gives me a circular reference because to instantiate a ButtonIRQ class I now have to do something like this: ButtonIRQ< InputPinIRQ< A1, ButtonIRQ<....>::OnPinChange, OnButtonChange > pB; where the <...... represents the circular reference. Does anyone know how I can avoid this circular reference? I am new to templates, so might be missing something really simple. It's important that the compiler knows exactly what code will be run when the interrupt occurs as it then does some very useful optimisation - it is able to inline the callback function and literally inserts the callback function's code at the exact address that is called on a h/w interrupt.

    Read the article

  • Best Practice for Context Processors vs. Template Tags?

    - by mawimawi
    In which cases is it better to create template tags (and load them into the template), than creating a context processor (which fills the request automatically)? e.g. I have a dynamic menu that has to be included into all templates, so I'm putting it into my base.html. What is the preferred usage: context processor or custom template tag? And why?

    Read the article

  • Using type passed as a template in C++

    - by MeDiCS
    Is it possible to actually use the type passed as a template for control flow? I'd like to write a function that uses templates, which in turn calls another function based on the type passed: template <class T> void test_function (T var) { //Do stuff if (T == char) { bar (var); } else { foo (var); } //Do even more stuff } If not, I'll have to fallback to enums...

    Read the article

  • Powerpoint template image placeholders can't send to back

    - by Marcus
    We want to be able to set up a PowerPoint 2007 template with a picture frame image. We then want to insert an image in normal view which would appear behind the picture frame image that was put in the template (so it looks logically like a picture in a picture frame). Problem is, when we insert the image in normal view it always appears on top of the picture frame image. It appears that you can't send to back when the other elements are included in a template. Any ideas?

    Read the article

  • How to dynamically reference a "partial template" in MS Word?

    - by scunliffe
    I want to make use of an "external reference" in Word. (for anyone that knows AutoCAD, I want XREF abilities in Word) Essentially I have a custom "header" that I want included in a whole pile of documents... that all reference a single file... such that if my address, logo, tagline, phone, fax or email changes, I update the one file, and all of the other 101 files that use it automatically update when I next open/use them. I'm using Office 2007 if that makes any difference.

    Read the article

  • How to create a template with contact info in Windows Live Mail?

    - by Elliott
    Is it possible to create a template to use in Windows Live mail which I can load peoples details into from my contact list? I currently send emails to people but I have to manually view them in the address book, then copy there details into an email. What I would like is to open the template, select the email address and everything else is auto completed, such as first name, address etc. These would go in set fields which I set within the template. Is this possible? I am willing to switch to another mail account if needed but I would prefer it to be in Windows Live Mail. Thank you. :)

    Read the article

  • How to create reusable fields in Word

    - by Mystere Man
    I would like to create reusable fields that I can type in, then reuse those fields throughout the document without having to retype them. As an example, I have a cover sheet that contains "Title", "Document ID", "Version Number", and "Published Date". I used the MACROBUTTON trick to create a field that someone can just click on and type, but I don't see how I can re-use what is typed in other parts of the document (such as putting the Document title in the header). I've found something called "fill-in" fields, which don't seem to be what i'm looking for, and "ASK" fields, but that creates a dialog that you have to enter the information into. I'm trying to create a generic template for my documentation needs. Can anyone suggest a method to do what I am looking for?

    Read the article

  • Insert set of fields/document properties automatically

    - by ngm
    I'm fairly new to Word 2007. (Coming more from a Linux/text editor background.) Each time I create a document within Word 2007, I add a set of details to the start of the document. It's the same set of details each time -- Author, Date Created, Date Last Modified, and Status, formatted in the same way each time. I include these bits of information either by inserting Fields (Insert -> Quick Parts -> Insert Field) or Document Properties (Insert -> Quick Parts -> Document Properties -> ...). I'm just wondering how I would go about setting up a macro or a template or something along those lines to insert this information automatically, either by a keypress in an existing document, or each time I start a new document.

    Read the article

  • ignore or override current document page formatting with predefined settings automatically libreoffice

    - by alex
    When opening a document made by someone else, I would like the margins to automatically be set to 0.4 cm, the page orientation to landscape and page size to A3. My dad gets emailed a spreadsheet weekly and he prints them off. To fit them onto one page he applies these settings, which is quite laborious. I thought that there must be a quicker way of doing this! I tried creating a new default template with these settings but this only works for a new blank document. I tried to create a style to quickly apply these settings but I realised these styles are document / template specific (?) and so don't appear when opening someone else's document. Anyone have any ideas how I can do this? Thanks =]

    Read the article

  • Creating different margins on the first page of a word template

    - by Paul
    I have a letterhead template and I need the first page left margin to be larger than subsequent pages. I've seen the option of placing a text box or image box in the header to push the text but this ends up throwing off the tabs and bullet list indentation markers. I thought of setting up the first page using two columns and pushing the text to start on the second column but I can't seem to find a way to get the text to switch back to 1 column on the second page when it is created from text overflowing. Does anyone know how something like this is possible? Thanks in advance, Paul

    Read the article

  • QuickBooks 2008 template formatting

    - by rotard
    I am trying to create an invoice template, and need to display the first line of the description in bold, with the rest of the description UNDER it, and NOT bold. Is there any way to do this, or do I need to look for a third party solution?

    Read the article

  • How would I template an SLS using saltstack

    - by user180041
    I'm trying to do proof of concept with Mongodb(sharding) and Id like to run a command every time I spin up a new cluster without having to add lines in all my sls files. My current init is as follows: mongo Replica4:27000 /usr/lib/mongo/init_addshard.js: cmd: - run - user: present The word Replica4 is not templated id like to know a way I would be able to do so, that way when I spin up a new cluster I wouldn't have to touch anything in this file.

    Read the article

  • PDF form (not) saving

    - by gregseth
    I've created a form in a PDF with Adobe Acrobat Pro. When empy, I want to use it as a template which the user opens, fills in, and saves as a copy to preserve the blank state of the template. Here's the trick : I found both ways to make the document read only - the user can't save the form value, only print them make the document writeable, but in this case the document acting as a template can be modified too. Any ideas? Thanks.

    Read the article

  • Is it okay to showcase templates/layouts recreated in different codes in a portfolio?

    - by Souta
    I have several different templates/layouts, both simple and complex. I recreated these templates multiple times, just using different codes. (Say, a complex one was originally made in only HTML and CSS, I recreated it using HTML, Javascript, CSS, then again with a HTML and PHP concoction, and etc.) I wanted to showcase my work and skills by doing this, but I don't know if it would be okay for that all to go into a resumé/portfolio. This is why: Freelancing Does potential business really care about how their site is made, as long as it looks and functions to their liking? (As in, should I just only show the one example of each template/layout and not the multiple recreations?) Potential Hire However, if a potential employer were to stumble across my resumé/portfolio, would having the multiple recreations do any good for a career outlook? (As in, this potential employer is a company where I could be working on a team to create/develop sites and not be freelancing; would a lack of skill-shining turn this employer away because I didn't set myself apart and show that I'm not just like every other budding web designer?) Those two issues have me wondering if it is okay to have a resumé/portfolio combined for this specific reason. Or does something like this not matter to potential business (as a freelancer) because they wouldn't care either way as long as it looks and functions to their liking and therefore it is okay to showcase the recreations with the originals?

    Read the article

  • Reordering Variadic Parameters

    - by void-pointer
    I have come across the need to reorder a variadic list of parameters that is supplied to the constructor of a struct. After being reordered based on their types, the parameters will be stored as a tuple. My question is how this can be done so that a modern C++ compiler (e.g. g++-4.7) will not generate unnecessary load or store instructions. That is, when the constructor is invoked with a list of parameters of variable size, it efficiently pushes each parameter into place based on an ordering over the parameters' types. Here is a concrete example. Assume that the base type of every parameter (without references, rvalue references, pointers, or qualifiers) is either char, int, or float. How can I make it so that all the parameters of base type char appear first, followed by all of those of base type int (which leaves the parameters of base type float last). The relative order in which the parameters were given should not be violated within sublists of homogeneous base type. Example: foo::foo() is called with arguments float a, char&& b, const float& c, int&& d, char e. The tuple tupe is std::tuple<char, char, int, float, float>, and it is constructed like so: tuple_type{std::move(b), e, std::move(d), a, c}. Consider the struct defined below, and assume that the metafunction deduce_reordered_tuple_type is already implemented. How would you write the constructor so that it works as intended? If you think that the code for deduce_reodered_tuple_type, would be useful to you, I can provide it; it's a little long. template <class... Args> struct foo { // Assume that the metafunction deduce_reordered_tuple_type is defined. typedef typename deduce_reordered_tuple_type<Args...>::type tuple_type; tuple_type t_; foo(Args&&... args) : t_{reorder_and_forward_parameters<Args>(args)...} {} }; Edit 1 The technique I describe above does have applications in mathematical frameworks that make heavy use of expression templates, variadic templates, and metaprogramming in order to perform aggressive inlining. Suppose that you wish to define an operator that takes the product of several expressions, each of which may be passed by reference, reference to const, or rvalue reference. (In my case, the expressions are conditional probability tables and the operation is the factor product, but something like matrix multiplication works suitably as well.) You need access to the data provided by each expression in order to evaluate the product. Consequently, you must move the expressions passed as rvalue references, copy the expressions passed by reference to const, and take the addresses of expressions passed by reference. Using the technique I describe above now poses several benefits. Other expressions can use uniform syntax to access data elements from this expression, since all of the heavy-lifting metaprogramming work is done beforehand, within the class. We can save stack space by grouping the pointers together and storing the larger expressions towards the end of the tuple. Implementing certain types of queries becomes much easier (e.g. check whether any of the pointers stored in the tuple aliases a given pointer). Thank you very much for your help!

    Read the article

  • how do you use ${word_selection} in an Eclipse PDT template?

    - by pocketfullofcheese
    I was recently trying to use some code templates with Eclipse PDT 2.1 to speed up some common tasks. We use a lot of getters/setters, so I wrote the following template. function get${word_selection}() { return $$this->getData('${word_selection}'); } function set${word_selection}($$${word_selection}) { $$this->setData('${word_selection}', $$${word_selection}); } I named the template "getset" and the only way I know to use the Code Assist is to type: "getset" then hit my code assist keys (I have it set to Esc, but I think the default was Ctrl+Space). The problem is, this doesn't actually let me select a word to be used by the ${word_selection}. My question is: how do I type in my template name, hit the key combo, and have a word selected all at the same time?

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >