Omgili - forum search, search forums  
  

Discussions about template struct

Displaying 1 - 10 out of 5,469 discussions.  
Time Frame: (Any time)   Minimum number of replies: (2)   Minimum number of discussing users: (0)
  |  

Page: 1   2   3   4   5   6   7   8   9   10  
Keep this page open to be updated with the newest discussions automatically.
I have code like this: template <typename T, typename U> struct MyStruct { T aType; U anotherType; }; class IWantToBeFriendsWithMyStruct { friend struct MyStruct; //what is the correct syntax here ? }; What is the correct syntax to give friendship...
Started by on , 4 posts by 4 people.  
IWantToBeFriendsWithMyStruct { template <typename T, typename U> friend struct MyStruct; }; Works in VS2008 be class IWantToBeFriendsWithMyStruct { template <typename T, typename U> friend struct MyStruct; }.
I have a template class defined as follow : template <class T1, class T2> class MyClass { }; In this class, I need a struct that contains one member of type T1. How can I do that ? I tried the following, but it didn't work : template <class T...
Started by on , 4 posts by 4 people.  
template <class T1> struct myStruct{ T1 templateMember; // rest of members }; template < }; Just remove typedef: template <class T1, class T2> class MyClass { struct myStruct{ T1 templateMember; // rest....
I am specializing the 'less' (predicate) for a data type. The code looks like this: template<> struct std::less<DateTimeKey> { bool operator()(const DateTimeKey& k1, const DateTimeKey& k2) const { // Some code ... } } When compiling (g++ 4...
Started by on , 5 posts by 5 people.  
So struct A { A(int _v=0):v(_v){} int v; }; template<> struct less<A> { bool operator()(const A& k1, const A& k2) const { return k1.v < k2.v template specializations for....
Functor doesn't have to be in std namespace.
Ask your Facebook Friends
I have a template struct tree_parse_info declared as follows: template < typename IteratorT, typename NodeFactoryT, typename T > struct tree_parse_info { // ... }; The compiler allows the follows code: tree_parse_info<> m_info; Why does this...
Started by on , 4 posts by 4 people.  
struct array; // actual definition template <typename T , size_t N> struct array {}; int main(void = 10> struct array; // error: redefinition of default parameter template <typename T = double accidentally....
Is there an easier way to display the struct fields and their corresponding values in RichEdit control? This is what I am doing now: AnsiString s; s = IntToStr(wfc.fontColor); RichEdit1->Lines->Append(s); etc... Is there an easier way than having...
Started by on , 10 posts by 9 people.  
I suggest creating templated methods for writing to the text box: template <_To_Textbox(member1, "member1", textbox....
Richedit_stream(TRichEditControl &trc) : ctrl(trc) {} template <class T> richedit_stream minimal investment.
Hi all! I have the following class CppProperty class that holds value: template<typename TT> class CppProperty { TT val; public: CppProperty(void) { } CppProperty(TT aval) : val(aval) { } CppProperty(const CppProperty & rhs) { this->val = rhs...
Started by on , 4 posts by 4 people.  
You'd need a conversion operator: operator const TT&(void) const { return val; } operator TT&(void) { return val; } There is a brief tutorial on conversion operators... .
You need to provide operator int() to your class to allow the implicit conversion to int .
Let's suppose I have a struct like this: struct my_struct { int a; int b; } I have a function which should set a new value for either "a" or "b". This function also requires to specify which variable to set. A typical example would be like this: void ...
Started by on , 9 posts by 8 people.  
struct ctmap; We then specialise this for the case where there are no fields: template <>You can't use templates to solve this, but why use a struct in te first place? This seems like of a struct/class that does....
Hello! How can I do something like that (just an example): any_struct *my_struct = create_struct(); add_struct_member(my_struct, "a", int_member); add_struct_member(my_struct, "b", float_member); So that I could load and use a struct instance "from the...
Started by on , 4 posts by 4 people.  
The "insance" method will essentially create a new hashtable with equal number of members as the template hashtable....
The "create_struct of the struct.
Of discussion I'm just going to assume you have some sort of hashtable available .
This doesn't compile: template<class X> struct A { template<int I> void f() {} }; template<class T> void g() { A<T> a; a.f<3>(); // Compilation fails here (Line 18) } int main(int argc, char *argv[]) { g<int>(); // ...
Started by on , 4 posts by 4 people.  
Or ->-expression or qualified-id explicitly....
T> void g() { A<T> a; a.template f<3>(); // add `template` keyword here } According to C++'03 Standard 14.2/4: When the name of a member template specialization appears after .
MSDN says that you should use structs when you need lightweight objects. Are there any other scenarios when a struct is preferable over a class? Edit: Some people have forgotten that: 1. structs can have methods! 2. structs have no inheritance capabilites...
Started by on , 12 posts by 12 people.  
Structs are copy-the-difference-between-struct....
Time one might choose struct instead of class is for template metaprogramming as shorthand for classUse a struct when you want value-type semantics instead of reference-type.
Page: 1   2   3   4   5   6   7   8   9   10  
More Information


Forum Search About Omgili Help Plugins Forum/Board Owners Privacy

i
In Title
In Topic
In Reply
Exclude
Boost