diff options
author | shermp <14854761+shermp@users.noreply.github.com> | 2022-05-08 23:52:14 +0300 |
---|---|---|
committer | shermp <14854761+shermp@users.noreply.github.com> | 2022-05-08 23:52:14 +0300 |
commit | 7f756c143749c45adc8440a1df0b062703457bdc (patch) | |
tree | 327ced0faccf7ef28ff45bffb5553b1320abed1b | |
parent | fe100b801fcb2729b326c63718cf8c072c0a8875 (diff) |
Add message to static assert, Review changessp/progstart-refactor-1
-rw-r--r-- | include/programs.h | 2 | ||||
-rw-r--r-- | src/misc/programs.cpp | 7 |
2 files changed, 4 insertions, 5 deletions
diff --git a/include/programs.h b/include/programs.h index 94bca512d..7607217a7 100644 --- a/include/programs.h +++ b/include/programs.h @@ -105,7 +105,7 @@ void PROGRAMS_MakeFile(char const * const name, PROGRAMS_Creator creator); template<class P> std::unique_ptr<Program> ProgramCreate() { // ensure that P is derived from Program - static_assert(std::is_base_of_v<Program, P>); + static_assert(std::is_base_of_v<Program, P>, "class not derived from Program"); return std::make_unique<P>(); } diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index 463c3c98b..eb8fa6737 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -80,7 +80,7 @@ void PROGRAMS_MakeFile(const char *name, PROGRAMS_Creator creator) // Register the program's main pointer // NOTE: This step must come after the index is saved in the COM data - internal_progs.push_back(creator); + internal_progs.emplace_back(creator); } static Bitu PROGRAMS_Handler(void) { @@ -97,9 +97,8 @@ static Bitu PROGRAMS_Handler(void) { 256 + static_cast<uint16_t>(exec_block_size)); HostPt writer=(HostPt)&index; for (;size>0;size--) *writer++=mem_readb(reader++); - if (index >= internal_progs.size()) E_Exit("something is messing with the memory"); - PROGRAMS_Creator creator = internal_progs[index]; - auto new_program = creator(); + const PROGRAMS_Creator& creator = internal_progs.at(index); + const auto new_program = creator(); new_program->Run(); return CBRET_NONE; } |