QuISP
Loading...
Searching...
No Matches
Value.h
Go to the documentation of this file.
1#pragma once
2#include "types.h"
3
4namespace quisp::runtime {
5
13
15enum class ValueType {
16 INT,
18};
19
22 public:
25
27 int intValue() const {
28 if (type != ValueType::INT) throw std::runtime_error("the value is not an integer");
29 return val.int_value;
30 }
31
34 if (type != ValueType::MEASUREMENT_OUTCOME) throw std::runtime_error("the value is not a MeasurementOutcome");
35 return val.outcome;
36 }
37
39
40 private:
42};
43
44std::ostream& operator<<(std::ostream& stream, const MemoryValue& value);
45
46} // namespace quisp::runtime
memory value
Definition Value.h:21
MemoryValue(MeasurementOutcome val)
Definition Value.h:24
ValueUnion val
Definition Value.h:41
int intValue() const
return integer value if the type check passed.
Definition Value.h:27
ValueType type
Definition Value.h:38
MeasurementOutcome outcome() const
returns measurement outcome if the type check passed.
Definition Value.h:33
MemoryValue(int val)
Definition Value.h:23
Definition InstructionVisitor.cc:7
ValueType
enum for memory value types
Definition Value.h:15
std::ostream & operator<<(std::ostream &stream, const QNodeAddr &value)
Definition types.cc:10
this file contains the definitions of all the user-defined types widely used alongside the runtime::R...
actual memory value that can hold multiple types of values.
Definition Value.h:7
MeasurementOutcome outcome
Definition Value.h:9
ValueUnion(MeasurementOutcome val)
Definition Value.h:11
ValueUnion(int val)
Definition Value.h:10
int int_value
Definition Value.h:8