Minor tweak for better StateVector error messages

If you use StateVector<Block*,...> or similar on accident,
you get a bunch of junk.  Add a static_assert so there's at least a
reasonable error in there somewhere.
Esse commit está contido em:
Jordan DeLong
2013-05-26 14:53:26 -07:00
commit de sgolemon
commit 03c652cb3c
@@ -17,6 +17,8 @@
#ifndef incl_HPHP_JIT_STATE_VECTOR_H_
#define incl_HPHP_JIT_STATE_VECTOR_H_
#include <type_traits>
#include "hphp/runtime/base/memory/memory_manager.h"
#include "hphp/runtime/vm/translator/hopt/irfactory.h"
@@ -39,6 +41,13 @@ struct StateVector {
typedef typename InfoVector::reference reference;
typedef typename InfoVector::const_reference const_reference;
static_assert(
std::is_same<Key,Block>::value ||
std::is_same<Key,IRInstruction>::value ||
std::is_same<Key,SSATmp>::value,
"StateVector can only be used with Block, IRInstruction, or SSATmp"
);
StateVector(const IRFactory* factory, Info init)
: m_factory(factory)
, m_info(numIds(factory, static_cast<Key*>(nullptr)), init)