# HG changeset patch # User Brian Neal # Date 1341275029 18000 # Node ID 919b7a0d18027473f68d925c19eb0fc7cea1adf0 # Parent b9d124a1592615c0a42d73f8f1c94cefb63c5b91 Ditched shared_ptr. diff -r b9d124a15926 -r 919b7a0d1802 enigma/machine.cpp --- a/enigma/machine.cpp Mon Jul 02 19:14:36 2012 -0500 +++ b/enigma/machine.cpp Mon Jul 02 19:23:49 2012 -0500 @@ -16,12 +16,12 @@ enigma_machine::enigma_machine( const rotor_vector& rv, - std::shared_ptr reflector, + const rotor& reflector, const plugboard& pb) : rotors(), pb(pb) { - rotors.push_back(*reflector); + rotors.push_back(reflector); for (const auto& r : rv) { rotors.push_back(*r); @@ -33,11 +33,11 @@ enigma_machine::enigma_machine( const rotor_vector& rv, - std::shared_ptr reflector) + const rotor& reflector) : rotors(), pb() { - rotors.push_back(*reflector); + rotors.push_back(reflector); for (const auto& r : rv) { rotors.push_back(*r); diff -r b9d124a15926 -r 919b7a0d1802 enigma/machine.h --- a/enigma/machine.h Mon Jul 02 19:14:36 2012 -0500 +++ b/enigma/machine.h Mon Jul 02 19:23:49 2012 -0500 @@ -16,7 +16,7 @@ namespace enigma { - typedef std::vector> rotor_vector; + typedef std::vector rotor_vector; class enigma_machine_error : public enigma_error { @@ -29,14 +29,16 @@ class enigma_machine { public: - // construct an Enigma machine from component parts: + // Construct an Enigma machine from component parts. + // Note that the enigma_machine makes copies of the rotors and will not + // delete the rotor pointers: enigma_machine(const rotor_vector& rv, - std::shared_ptr reflector, + const rotor& reflector, const plugboard& pb); // construct an Enigma machine with a default plugboard (no cables connected): enigma_machine(const rotor_vector& rv, - std::shared_ptr reflector); + const rotor& reflector); // key-sheet style constructors: enigma_machine(const std::vector& rotor_types,