#define ENUM_H
-#include <assert.h>
#include <string>
#include <vector>
#include <algorithm>
+#include <exception>
#include "snapper/Snapshot.h"
#include "snapper/AppUtil.h"
using std::vector;
+ struct OutOfRangeException : public std::exception
+ {
+ explicit OutOfRangeException() throw() {}
+ virtual const char* what() const throw() { return "out of range"; }
+ };
+
+
template <typename EnumType> struct EnumInfo {};
template <> struct EnumInfo<SnapshotType> { static const vector<string> names; };
// Comparisons must not be done with type of enum since the enum may
// define comparison operators.
- assert((size_t)(value) < names.size());
+ if ((size_t)(value) >= names.size())
+ throw OutOfRangeException();
return names[value];
}