Search Results

Search found 3563 results on 143 pages for 'templates'.

Page 5/143 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to use two templates for ListViewItem using WPF

    - by Gregor
    Hi, I would like to have a ListView that would have have items similar to Microsoft Outlook inbox with items arranged by Conversations (see the attached photo). An item can either be a simple textblock containing the topic of the conversation (on the photo this are the blue lines) or it can contain email information specified by the ListView's header. It would be best if the items with conversation topics would be push buttons so that emails inside that conversation could be shown or hidden by pressing this button. Any ideas how can I achieve this? Do I specify two ListViewItem templates? If yes, how do I tell in the code which template to use for each item? Any help will be GREATLY appreciated!! Regards, Gregor

    Read the article

  • Missing templates after re-installing VS 2008

    - by ray247
    I installed VS 2008 and I installed .NET 3.5 SP1 and I got all templates. Then, I had to uninstall VS 2008 (please don't ask why) without uninstalling .NET Framework 3.5 SP1 or anything else. After that, I re-installed VS 2008 back, then I open up VS 2008 and found that when I add a new item the Entity Framework template is not among the list anymore. Could someone please help on how to resolve this problem? Thank you so much! Ray.

    Read the article

  • can these templates be made unambiguous

    - by R Samuel Klatchko
    I'm trying to create a set of overloaded templates for arrays/pointers where one template will be used when the compiler knows the size of the array and the other template will be used when it doesn't: template <typename T, size_t SZ> void moo(T (&arr)[SZ]) { ... } template <typename T> void moo(T *ptr) { ... } The problem is that when the compiler knows the size of the array, the overloads are ambiguous and the compile fails. Is there some way to resolve the ambiguity (perhaps via SFINAE) or is this just not possible.

    Read the article

  • Design Web Templates

    - by Pradeep
    Hi, I am a PHP, VB.NET programmer and i like to build websites. I am good at coding but have never done website designing. Please suggest me some good study resource on Photoshop and flash website design. I have recently made few templates on photoshop but don't know how to code them for valid HTML-CSS. Please let me know which is the best method to design website template e.g. Photoshop, DreamWeaver etc. Also provide links to good study and practice resource for the same. Thanks in advance.

    Read the article

  • Implement the Combine function using templates

    - by gkid123
    any idea on how to do it for template? thanks Implement the Combine function using templates. The Combine fn applies a function of two arguments cumulatively to the items of an STL container, from begin() to end(), so as to reduce the sequence to a single value. For example, Combine(<list containing 6,3,1,9,7>, std::plus<int>()) should calculate ((((6+3)+1)+9)+7). class NotEnoughElements {}; template <typename Container, typename Function> typename Container::value_type Combine(const Container& c, Function fn) throw (NotEnoughElements) { your code goes here }

    Read the article

  • Question regarding C++ Templates

    - by Isuru
    I used a simple class for a test program about templates, this is what I did: template <typename T> class test { public: test<T>::test(); T out(); }; template <typename T> test<T>::test() { } T test<T>::out() { } int main() { //test<int> t; } But when I try to compile it says 'T' : undeclared identifier and use of class template requires template argument list , pointing to the same line, where I have implemented the method out() . Can anyone please explain what the problem is?? I'm using visual studio 2008.

    Read the article

  • Can I move the order of XCode, Cocoa, and User Templates around in XCode 3.1?

    - by Warren P
    I followed the other questions on StackOverflow and made custom User Templates. Instead of replacing the factory default Cocoa class template, I have to pick a new user template. The order that is shown in XCode's New File dialog box is: iPhone templates first (great if you mostly do iphone development) Second the User templates Third the default Mac OS templates. I want my user stuff first, Mac OS templates second, and I want to bury iPhone templates in third and last place. The sort is obviously not alphabetical. And you can't drag/drop reorder. (At least not in xcode 3.1.3)? From stackoverflow

    Read the article

  • Not work variables in django templates

    - by ??????? ???????
    My context dictionary not sending to my templates. I have function from django.shortcuts import render_to_response def home(request): return render_to_response('home.html',{'test':'test'}) and i have simple template such as: <html> <body> my test == {{test}} </body> </html> When i open my site in browser, i have "my test == ". settings.py is default. I dont use something custom. What the problem? Server is apache with wsgi module.

    Read the article

  • Django dictionary in templates: Grab key from another objects attribute

    - by Jordan Messina
    I have a dictionary called number_devices I'm passing to a template, the dictionary keys are the ids of a list of objects I'm also passing to the template (called implementations). I'm iterating over the list of objects and then trying to use the object.id to get a value out of the dict like so: {% for implementation in implementations %} {{ number_devices.implementation.id }} {% endfor %} Unfortunately number_devices.implementation is evaluated first, then the result.id is evaluated obviously returning and displaying nothing. I can't use parentheses like: {{ number_devices.(implementation.id) }} because I get a parse error. How do I get around this annoyance in Django templates? Thanks for any help!

    Read the article

  • How do I compile variadic templates conditionally?

    - by FredOverflow
    Is there a macro that tells me whether or not my compiler supports variadic templates? #ifdef VARIADIC_TEMPLATES_AVAILABLE template<typename... Args> void coolstuff(Args&&... args); #else ??? #endif If they are not supported, I guess I would simulate them with a bunch of overloads. Any better ideas? Maybe there are preprocessor libraries that can ease the job?

    Read the article

  • Using Django view variables inside templates

    - by William
    Hi, this is a rather basic question (I'm new to Django) but I'm having trouble using a variable set in my view inside my template. If I initialize a string or list inside my view (i.e. h = "hello") and then attempt to call it inside a template: {{ h }} there is neither output nor errors. Similarly, if I try to use a variable inside my template that doesn't exist: {{ asdfdsadf }} there is again no error reported. Is this normal? And how can I use my variables within my templates. Thanks!

    Read the article

  • Polymorphic classes in templates

    - by soxarered
    Let's say we have a class hierarchy where we have a generic Animal class, which has several classes directly inherit from it (such as Dog, Cat, Horse, etc..). When using templates on this inheritance hierarchy, is it legal to just use SomeTemplateClass<Animal> and then shove in Dogs and Cats and Horses into this templated object? For example, assume we have a templated Stack class, where we want to host all sorts of animals. Can I simply state Stack<Animal> s; Dog d; s.push(d); Cat c; s.push(c);

    Read the article

  • Template function in C# - Return Type?

    - by LifeH2O
    It seems that c# does not support c++ like templates. template <class myType> myType GetMax (myType a, myType b) { return (a>b?a:b); } I want my function to have return type based on its parameters, how can i achieve this in c#? How to use templates in C#

    Read the article

  • C++ templates - matrix class

    - by lastOfMohicans
    Hi I'm learning templates in C++ so I decied to write matrix class which would be a template class. In Matrix.h file I wrote #pragma once #include "stdafx.h" #include <vector> using namespace std; template<class T> class Matrix { public: Matrix(); ~Matrix(); GetDataVector(); SetDataVector(vector<vector<T>> dataVector); bool operator == (Matrix* matrix); bool operator < (Matrix* matrix); bool operator <= (Matrix* matrix); bool operator > (Matrix* matrix); bool operator >= (Matrix* matrix); Matrix* operator + (Matrix* matrix); Matrix* operator - (Matrix* matrix); Matrix* operator * (Matrix* matrix); private: vector<vector<T>> datavector; int columns,rows; }; In Matrix cpp Visual Stuio automaticlly generated code for default constructors #include "StdAfx.h" #include "Matrix.h" Matrix::Matrix() { } Matrix::~Matrix() { } However if I want to compile this I get an error 'Matrix' : use of class template requires template argument list The error are in file Matrix.cpp in default constructors What may be the problem ??

    Read the article

  • Templates, and C++ operator for logic: B contained by set A

    - by James Morris
    In C++, I'm looking to implement an operator for selecting items in a list (of type B) based upon B being contained entirely within A. In the book "the logical design of digital computers" by Montgomery Phister jr (published 1958), p54, it says: F11 = A + ~B has two interesting and useful associations, neither of them having much to do with computer design. The first is the logical notation of implication... The second is notation of inclusion... This may be expressed by a familiar looking relation, B < A; or by the statement "B is included in A"; or by the boolean equation F11= A + ~B = 1. My initial implementation was in C. Callbacks were given to the list to use for such operations. An example being a list of ints, and a struct containting two ints, min and max, for selection purposes. There, selection would be based upon B = A-min && B <= A-max. Using C++ and templates, how would you approach this after having implemented a generic list in C using void pointers and callbacks? Is using < as an over-ridden operator for such purposes... <ugh> evil? </ugh> (or by using a class B for the selection criteria, implementing the comparison by overloading ?)

    Read the article

  • How to properly use references with variadic templates

    - by Hippicoder
    I have something like the following code: template<typename T1, typename T2, typename T3> void inc(T1& t1, T2& t2, T3& t3) { ++t1; ++t2; ++t3; } template<typename T1, typename T2> void inc(T1& t1, T2& t2) { ++t1; ++t2; } template<typename T1> void inc(T1& t1) { ++t1; } I'd like to reimplement it using the proposed variadic templates from the upcoming standard. However all the examples I've seen so far online seem to be printf like examples, the difference here seems to be the use of references. I've come up with the following: template<typename T> void inc(T&& t) { ++t; } template<typename T,typename ... Args> void inc(T&& t, Args&& ... args) { ++t inc(args...); } What I'd like to know is: Should I be using r-values instead of references? Possible hints or clues as to how to accomplish what I want correctly. What guarantees does the new proposed standard provide wrt the issue of the recursive function calls, is there some indication that the above variadic version will be as optimal as the original? (should I add inline or some-such?)

    Read the article

  • how to number t-rows ,when table generated using nested forloop in django templates

    - by stackover
    Hi, This part is from views.py results=[(A,[stuObj1,stuObj2,stuObj3]),(B,[stuObj4,stuObj5,stuObj6]),(C,[stuObj7,stuObj8])] for tup in results: total = tot+len(tup[1]) render_to_response(url,{'results':res , 'total':str(tot),}) this is template code: <th class="name">Name</th> <th class="id">Student ID</th> <th class="grade">Grade</th> {% for tup in results %} {% for student in tup|last %} {% with forloop.parentloop.counter as parentid%} {% with forloop.counter as centerid%} <tbody class="results-body"> <tr> <td>{{student.fname|lower|capfirst}} {{student.lname|lower|capfirst}}</td> <td>{{student.id}}</td> <td>{{tup|first}}</td> </tr> {% endfor %} {% endfor %} Now the problems am having are 1. numbering the rows. Here my problem is am not sure if i can do things like total=total-1 in the templates to get the numbered rows like <td>{{total}}</td> 2.applying css to tr:ever or odd. Whats happening in this case is everytime the loop is running the odd/even ordering is lost. these seems related problems. Any ideas would be great :)

    Read the article

  • Using Subsonic 3.0 Advanced Templates

    - by umit
    Hi all, I've been trying to use Subsonic Advanced Templates in a project for a while but most of the time I find myself writing a Stored Procedure as I can't find a proper way of doing it in code. Subsonic created corresponding objects for my DB tables and for foreign keys it created IQueryable fields inside each object. These fields are not loaded by default and a new SQL query is executed when you access them. 1- Is there a way to get all data in one query (deep load)? Also these fields can not be assigned. So when I want to create an object in a maintenance page, I can't put all the data into this object before saving it in DB: Post post = new Post(); //get photos for this post IList<PostPhoto> postPhotos = GetPostPhotos(); post.PostPhotos = postPhotos; 2- Is it possible to have one Post object with all fields set from user input? Think of the Post object above and assume I've successfully assigned its fields. Now I need to save it to the DB. 3- Is using BatchQuery the only way to do it in one query? If I have 4 photos in PostPhotos field; 2 of them previously saved and 2 of them new, can I use the Update method to handle both the adding and updating of these photos? Any ideas or links are appreciated. Cheers...

    Read the article

  • Recursive templates: compilation error under g++

    - by Johannes
    Hi, I am trying to use templates recursively to define (at compile-time) a d-tuple of doubles. The code below compiles fine with Visual Studio 2010, but g++ fails and complains that it "cannot call constructor 'point<1::point' directly". Could anyone please shed some light on what is going on here? Many thanks, Jo #include <iostream> #include <utility> using namespace std; template <const int N> class point { private: pair<double, point<N-1> > coordPointPair; public: point() { coordPointPair.first = 0; coordPointPair.second.point<N-1>::point(); } }; template<> class point<1> { private: double coord; public: point() { coord= 0; } }; int main() { point<5> myPoint; return 0; }

    Read the article

  • C++ Namespaces & templates question

    - by Kotti
    Hi! I have some functions that can be grouped together, but don't belong to some object / entity and therefore can't be treated as methods. So, basically in this situation I would create a new namespace and put the definitions in a header file, the implementation in cpp file. Also (if needed) I would create an anonymous namespace in that cpp file and put all additional functions that don't have to be exposed / included to my namespace's interface there. See the code below (probably not the best example and could be done better with another program architecture, but I just can't think of a better sample...) Sample code (header) namespace algorithm { void HandleCollision(Object* object1, Object* object2); } Sample code (cpp) #include "header" // Anonymous namespace that wraps // routines that are used inside 'algorithm' methods // but don't have to be exposed namespace { void RefractObject(Object* object1) { // Do something with that object // (...) } } namespace algorithm { void HandleCollision(Object* object1, Object* object2) { if (...) RefractObject(object1); } } So far so good. I guess this is a good way to manage my code, but I don't know what should I do if I have some template-based functions and want to do basically the same. If I'm using templates, I have to put all my code in the header file. Ok, but how should I conceal some implementation details then? Like, I want to hide RefractObject function from my interface, but I can't simply remove it's declaration (just because I have all my code in a header file)... The only approach I came up with was something like: Sample code (header) namespace algorithm { // Is still exposed as a part of interface! namespace impl { template <typename T> void RefractObject(T* object1) { // Do something with that object // (...) } } template <typename T, typename Y> void HandleCollision(T* object1, Y* object2) { impl::RefractObject(object1); // Another stuff } } Any ideas how to make this better in terms of code designing?

    Read the article

  • c++ templates and inheritance

    - by Armen Ablak
    Hey, I'm experiencing some problems with breaking my code to reusable parts using templates and inheritance. I'd like to achieve that my tree class and avltree class use the same node class and that avltree class inherits some methods from the tree class and adds some specific ones. So I came up with the code below. Compiler throws an error in tree.h as marked below and I don't really know how to overcome this. Any help appreciated! :) node.h: #ifndef NODE_H #define NODE_H #include "tree.h" template <class T> class node { T data; ... node() ... friend class tree<T>; }; #endif tree.h #ifndef DREVO_H #define DREVO_H #include "node.h" template <class T> class tree { public: //signatures tree(); ... void insert(const T&); private: node<T> *root; //missing type specifier - int assumed. Note: C++ does not support default-int }; //implementations #endif avl.h #ifndef AVL_H #define AVL_H #include "tree.h" #include "node.h" template <class T> class avl: public tree<T> { public: //specific int findMin() const; ... protected: void rotateLeft(node<T> *)const; private: node<T> *root; }; #endif avl.cpp (I tried separating headers from implementation, it worked before I started to combine avl code with tree code) #include "drevo" #include "avl.h" #include "vozlisce.h" template class avl<int>; //I know that only avl with int can be used like this, but currently this is doesn't matter :) //implementations ...

    Read the article

  • C++ Templates: Convincing self against code bloat

    - by ArunSaha
    I have heard about code bloats in context of C++ templates. I know that is not the case with modern C++ compilers. But, I want to construct an example and convince myself. Lets say we have a class template< typename T, size_t N > class Array { public: T * data(); private: T elems_[ N }; }; template< typename T, size_t N > T * Array<T>::data() { return elems_; } Further, let's say types.h contains typedef Array< int, 100 > MyArray; x.cpp contains MyArray ArrayX; and y.cpp contains MyArray ArrayY; Now, how can I verify that the code space for MyArray::data() is same for both ArrayX and ArrayY? What else I should know and verify from this (or other similar simple) examples? If there is any g++ specific tips, I am interested for that too. PS: Regarding bloat, I am concerned even for the slightest of bloats, since I come from embedded context.

    Read the article

  • Get type of the parameter from list of objects, templates, C++

    - by CrocodileDundee
    This question follows to my previous question Get type of the parameter, templates, C++ There is the following data structure: Object1.h template <class T> class Object1 { private: T a1; T a2; public: T getA1() {return a1;} typedef T type; }; Object2.h template <class T> class Object2: public Object1 <T> { private: T b1; T b2; public: T getB1() {return b1;} } List.h template <typename Item> struct TList { typedef std::vector <Item> Type; }; template <typename Item> class List { private: typename TList <Item>::Type items; }; Is there any way how to get type T of an object from the list of objects (i.e. Object is not a direct parameter of the function but a template parameter)? template <class Object> void process (List <Object> *objects) { typename Object::type a1 = objects[0].getA1(); // g++ error: 'Object1<double>*' is not a class, struct, or union type } But his construction works (i.e. Object represents a parameter of the function) template <class Object> void process (Object *o1) { typename Object::type a1 = o1.getA1(); // OK }

    Read the article

  • Templates, Function Pointers and C++0x

    - by user328543
    One of my personal experiments to understand some of the C++0x features: I'm trying to pass a function pointer to a template function to execute. Eventually the execution is supposed to happen in a different thread. But with all the different types of functions, I can't get the templates to work. #include `<functional`> int foo(void) {return 2;} class bar { public: int operator() (void) {return 4;}; int something(int a) {return a;}; }; template <class C> int func(C&& c) { //typedef typename std::result_of< C() >::type result_type; typedef typename std::conditional< std::is_pointer< C >::value, std::result_of< C() >::type, std::conditional< std::is_object< C >::value, std::result_of< typename C::operator() >::type, void> >::type result_type; result_type result = c(); return result; } int main(int argc, char* argv[]) { // call with a function pointer func(foo); // call with a member function bar b; func(b); // call with a bind expression func(std::bind(&bar::something, b, 42)); // call with a lambda expression func( [](void)->int {return 12;} ); return 0; } The result_of template alone doesn't seem to be able to find the operator() in class bar and the clunky conditional I created doesn't compile. Any ideas? Will I have additional problems with const functions?

    Read the article

  • C++, array declaration, templates, linker error

    - by justik
    There is a linker error in my SW. I am using the following structure based on h, hpp, cpp files. Some classes are templatized, some not, some have function templates. Declaration: test.h #ifndef TEST_H #define TEST_H class Test { public: template <typename T> void foo1(); void foo2 () }; #include "test.hpp" #endif Definition: test.hpp #ifndef TEST_HPP #define TEST_HPP template <typename T> void Test::foo1() {} inline void Test::foo2() {} //or in cpp file #endif CPP file: test.cpp #include "test.h" void Test::foo2() {} //or in hpp file as inline I have the following problem. The variable vars[] is declared in my h file test.h #ifndef TEST_H #define TEST_H char *vars[] = { "first", "second"...}; class Test { public: void foo(); }; #include "test.hpp" #endif and used as a local variable inside foo() method defined in hpp file as inline. test.hpp #ifndef TEST_HPP #define TEST_HPP inline void Test::foo() { char *var = vars[0]; //A Linker Error } #endif However, the following linker error occurs: Error 745 error LNK2005: "char * * vars" (?vars@@3PAPADA) already defined in test2.obj How and where to declare vars[] to avoid linker errors? After including #include "test.hpp" it is late to declare it...

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >