MCPcopy Create free account
hub / github.com/covscript/covscript / add_reserve_var

Method add_reserve_var

include/covscript/core/core.hpp:378–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376 }
377
378 void add_reserve_var(std::string_view reserve, bool is_mem_fn = false)
379 {
380 mIsMemFn = is_mem_fn;
381 if (!mIsVargs) {
382 std::vector<std::string> args{std::string(reserve)};
383 args.reserve(mArgs.size());
384 for (auto &name : mArgs) {
385 if (name != reserve)
386 args.emplace_back(std::move(name));
387 else
388 throw runtime_error("Overwrite the default argument \"" + std::string(reserve) + "\".");
389 }
390 std::swap(mArgs, args);
391 }
392#ifdef CS_DEBUGGER
393 std::string prefix, suffix;
394 auto lpos = mDecl.find('(') + 1;
395 auto rpos = mDecl.rfind(')');
396 prefix = mDecl.substr(0, lpos);
397 suffix = mDecl.substr(rpos);
398 if (mArgs.size() > 1 || mIsVargs)
399 mDecl = prefix + "this" + (mIsVargs ? ", ..." : ", ") + mDecl.substr(lpos, rpos - lpos) + suffix;
400 else
401 mDecl = prefix + "this" + suffix;
402#endif
403 }
404
405 std::size_t argument_count() const noexcept
406 {

Callers 1

set_mem_fnMethod · 0.80

Calls 4

runtime_errorClass · 0.85
sizeMethod · 0.80
swapFunction · 0.70
moveFunction · 0.50

Tested by

no test coverage detected