I have a problem with a “complex” outer constructor (for me anyway).
I have the following structure:
struct MQC
circuit_list::Vector{QuantumCircuit}
connector_list::Vector{Connector}
wire_list::Vector{Wire}
MQC() = new(Vector{QuantumCircuit}(), Vector{Connector}(), Vector{Wire}())
end
As you can see I have a very simple constructor creating empty vectors which the user can populate after with the two following two functions:
function MQCAddCircuit(mqc::MQC, newc::QuantumCircuit)::Bool
and
function MQCAddConnector(mqc::MQC, connec::Connector)::Bool
Both have, as an ultimate goal, to add elements in the two first Vector of the structure. But they have complicated consistency checking rules before performing the finale push!() and will return false and exist before if it fails to meet the requirements.
I would like to allow users to create an MQC structure by providing a vectors of circuits and a vector of connectors:
MQC(vector1::Vector{QuantumCircuit}(), vector2::Vector{Connector}()) = SOME_CODE.
(never mind the third vector, it’s for internal use and not seen by the user)
In SOME_CODE above, I want to call the two adding function in a loop to transfer the elements of vector1 and vector2 into the vectors of the structure.
How can I call MQCAddCircuit(mqc::MQC, newc::QuantumCircuit)?
In C++ language mqc would be “this” (if I may say so).
I need somehow to let the structure I am talking about itself. SOME_CODE would be like:
for circuit in vector1
MQCAddCircuit(this, circuit)
end
for connector in vector2
MQCAddConnector(this, connector)
end
Can a “C++ programmer converted to Julia” show me the light? Thanks.