🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Atman Binstock Thu, 19 Oct 1995 09:37
can publish non-type arg from template class?
#2249
Author: Atman Binstock
Date: Thu, 19 Oct 1995 09:37
31 lines
1309 bytes
C++ allows you to publish class-type template arguments
to class templates:
template<class T> struct X {
	typdef T the_type;
};

Will the C++ std allow a way to do this with non-type
template arguments?

The only two ways I can think of are:

template<int I> struct X {
	enum { the_int = I };
};
Drawback: can't do floats, let alone user-class types

template<int I> struct X {
	static const the_int = I;
};
Does this work?
Drawback: need to define the_int somewhere.
Will this work for an arbitrary user-defined class?


Thanks,
Atman Binstock
ajb@panix.com
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads