From 13347878df50f1421fdb73544ded91c201b0df05 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 28 Sep 2007 10:32:59 +0200 Subject: [PATCH] implement the helper IntToType template --- src/core/int-to-type.h | 19 +++++++++++++++++++ src/core/wscript | 1 + 2 files changed, 20 insertions(+) create mode 100644 src/core/int-to-type.h diff --git a/src/core/int-to-type.h b/src/core/int-to-type.h new file mode 100644 index 000000000..240fe8a71 --- /dev/null +++ b/src/core/int-to-type.h @@ -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 +struct IntToType +{ + enum {value = v}; +}; + +} // namespace ns3 + +#endif /* INT_TO_TYPE_H */ diff --git a/src/core/wscript b/src/core/wscript index c69bb018c..bfb784825 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -95,5 +95,6 @@ def build(bld): 'composite-trace-resolver.h', 'array-trace-resolver.h', 'trace-doc.h', + 'int-to-type.h', ]