473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

typedef with a template

Hello all,

can i typedef such a déclaration ??

template <class T, int i>
struct MyStruc
{
/* some members here ...*/
};

Thanks in advance

Xavier
Jul 10 '07 #1
5 1963
Xavier Serrand wrote:
can i typedef such a déclaration ??

template <class T, int i>
struct MyStruc
{
/* some members here ...*/
};
typedef MyStruct<int,42MyInt42Struct;

Beyond that, ask more particular questions.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 10 '07 #2
On Jul 10, 2:21 pm, "Xavier Serrand" <xxxxxx.xxxx...@xxx.frwrote:
Hello all,

can i typedef such a déclaration ??

template <class T, int i>
struct MyStruc
{
/* some members here ...*/

};

Thanks in advance

Xavier
You are restricted to giving the template type definition a specific
"for-instance:"

typedef MyStruc<int, 0intPoop;
typedef MyStruc<char, 1charPoop;
typedef MyStruc<float, 2floatPoop;

intPoop<chicken, 123456789henType; // Invalid
intPoop valid0; // Do these need comments? Yes, always!
charPoop valid1;
floatPoop valid2;

Jul 10 '07 #3

"Xavier Serrand" <xx************@xxx.fra écrit dans le message de
news:46**********************@news.orange.fr...
Hello all,

can i typedef such a déclaration ??

template <class T, int i>
struct MyStruc
{
/* some members here ...*/
};

Thanks in advance

Xavier

Ok this seems to work

template <class T, int i>
typedef struct MyStruc
{
/* some members here ...*/
} MyStructure;

Xavier
Jul 10 '07 #4

"Xavier Serrand" <xx************@xxx.fra écrit dans le message de
news:46**********************@news.orange.fr...
>
"Xavier Serrand" <xx************@xxx.fra écrit dans le message de
news:46**********************@news.orange.fr...
Hello all,

can i typedef such a déclaration ??

template <class T, int i>
struct MyStruc
{
/* some members here ...*/
};

Thanks in advance

Xavier

Ok this seems NOT to work

template <class T, int i>
typedef struct MyStruc
{
/* some members here ...*/
} MyStructure;

Xavier


Jul 10 '07 #5

"spekyuman" <sp*******@gmail.coma écrit dans le message de
news:11**********************@22g2000hsm.googlegro ups.com...
On Jul 10, 2:21 pm, "Xavier Serrand" <xxxxxx.xxxx...@xxx.frwrote:
Hello all,

can i typedef such a déclaration ??

template <class T, int i>
struct MyStruc
{
/* some members here ...*/

};

Thanks in advance

Xavier
You are restricted to giving the template type definition a specific
"for-instance:"

typedef MyStruc<int, 0intPoop;
typedef MyStruc<char, 1charPoop;
typedef MyStruc<float, 2floatPoop;

intPoop<chicken, 123456789henType; // Invalid
intPoop valid0; // Do these need comments? Yes, always!
charPoop valid1;
floatPoop valid2;
Thanks, Speykuman

I found a way to typedef my templated type as i wanted
Because T is defined in the class declaration, we can do :

template <typename Tclass CTemplated
{
typedef struct MyStruc<TMyStructureT;
MyStructureT m_one;
CTemplated(int n) {m_one.x = n;}
};
Xavier
Jul 10 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Arkadiy Vertleyb | last post by:
Hi all, I am having a problem trying to overload a function template, based on a typedef, such as: template<class T> struct A {}; template<class T>
5
by: Roger Leigh | last post by:
Although I've got over most of my template-related problems, I'm having trouble when I started to use default template parameters. For template type T, I've typedef'd this as object_type and then...
7
by: Tony Johansson | last post by:
Hello Experts! I have the following Array template class see below. I execute these three statements statement 1: Array<int> x(5); statement 2: cin >>x; statement 3: Array<int>::element_type ...
2
by: PengYu.UT | last post by:
I have the following sample program, which can convert function object with 1 argument into function object with 2 arguments. It can also do + between function object of the same type. The last...
2
by: Patrick Kowalzick | last post by:
Hello NG, sorry to bother again, but I am a lit surprised that I got no answer on my post (attached below). So I refined the code a little bit :-). If there is a typedefed class X inside a...
6
by: Alex | last post by:
Hello people, I am getting errors from VS2003 when working with typedef'ed types. For example, assume that I have a type T, defined in a 3rd party include file based on some condition #if...
5
by: jimmy | last post by:
I am trying to simulate typedef template similar to the suggestion of Herb Sutter in the following article: http://www.gotw.ca/gotw/079.htm However when implementing typedef templates according...
5
by: Alan Woodland | last post by:
Hi, I don't think I can't do this directly with standard C++, I've tried all the ways I could think of that make sense and then some. I was wondering if someone had a genius idea how I could...
12
by: aaragon | last post by:
Hello all. I have a simple question that seems trivial but I can't make it to work. I have a class that takes as a template argument, another class. The idea is as follows: #include...
3
by: Adam Nielsen | last post by:
Hi everyone, Yet another syntax problem that's baffling me with templates. I want to instantiate a template with a single parameter as per normal, however the parameter is actually a template...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.