implement the helper IntToType template
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 28 Sep 2007 10:32:59 +0200
changeset 1680 151684970a80
parent 1679 4160d5d5041d
child 1681 534caea78169
implement the helper IntToType template
src/core/int-to-type.h
src/core/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/int-to-type.h	Fri Sep 28 10:32:59 2007 +0200
@@ -0,0 +1,19 @@
+#ifndef INT_TO_TYPE_H
+#define INT_TO_TYPE_H
+
+namespace ns3 {
+
+/**
+ * This trivial template is extremely useful, as explained in
+ * "Modern C++ Design", p29, section 2.4, 
+ * "Mapping Integral Constants to Types"
+ */
+template <int v>
+struct IntToType
+{
+  enum {value = v};
+};
+
+} // namespace ns3
+
+#endif /* INT_TO_TYPE_H */
--- a/src/core/wscript	Fri Sep 28 10:32:15 2007 +0200
+++ b/src/core/wscript	Fri Sep 28 10:32:59 2007 +0200
@@ -95,5 +95,6 @@
         'composite-trace-resolver.h',
         'array-trace-resolver.h',
         'trace-doc.h',
+        'int-to-type.h',
         ]