This commit is contained in:
张壹 2025-02-03 15:41:30 +08:00
parent 8b294f61d6
commit 2ce5da95b0
6 changed files with 31 additions and 34 deletions

View File

@ -145,7 +145,7 @@ namespace gctl
*
* @param init_val Initial values
*/
array(std::initializer_list<ArrValType> init_val);
array(std::vector<ArrValType> init_val);
/**
* @brief Construct a new array object as a sequence
@ -394,7 +394,7 @@ namespace gctl
*
* @param init_val Initial values
*/
void resize(std::initializer_list<ArrValType> init_val);
void resize(std::vector<ArrValType> init_val);
/**
* @brief Resize a new array object as a sequence
@ -894,7 +894,7 @@ namespace gctl
}
template <typename ArrValType>
array<ArrValType>::array(std::initializer_list<ArrValType> init_val)
array<ArrValType>::array(std::vector<ArrValType> init_val)
{
length_ = 0;
val_ = nullptr;
@ -1244,15 +1244,12 @@ namespace gctl
}
template <typename ArrValType>
void array<ArrValType>::resize(std::initializer_list<ArrValType> init_val)
void array<ArrValType>::resize(std::vector<ArrValType> init_val)
{
resize(init_val.size());
typename std::initializer_list<ArrValType>::iterator iter = init_val.begin();
for (size_t i = 0; i < length_; i++)
{
val_[i] = *iter;
iter++;
val_[i] = init_val[i];
}
return;
}

View File

@ -114,7 +114,7 @@ namespace gctl
public:
runtime_error() : std::runtime_error("GCTL: Unexpected runtime error."){}
runtime_error(std::string estr) : std::runtime_error(("GCTL: Unexpected runtime error. "+estr).c_str()){}
virtual ~runtime_error(){}
//virtual ~runtime_error(){}
};
class range_error : public std::range_error
@ -122,7 +122,7 @@ namespace gctl
public:
range_error() : std::range_error("GCTL: Invalid range detected."){}
range_error(std::string estr) : std::range_error(("GCTL: Invalid range detected. "+estr).c_str()){}
virtual ~range_error(){}
//virtual ~range_error(){}
};
class overflow_error : public std::overflow_error
@ -130,7 +130,7 @@ namespace gctl
public:
overflow_error() : std::overflow_error("GCTL: Overflow error."){}
overflow_error(std::string estr) : std::overflow_error(("GCTL: Overflow error. "+estr).c_str()){}
virtual ~overflow_error(){}
//virtual ~overflow_error(){}
};
class underflow_error : public std::underflow_error
@ -138,7 +138,7 @@ namespace gctl
public:
underflow_error() : std::underflow_error("GCTL: Underflow error."){}
underflow_error(std::string estr) : std::underflow_error(("GCTL: Underflow error. "+estr).c_str()){}
virtual ~underflow_error(){}
//virtual ~underflow_error(){}
};
@ -147,7 +147,7 @@ namespace gctl
public:
logic_error() : std::logic_error("GCTL: Logic error."){}
logic_error(std::string estr) : std::logic_error(("GCTL: Logic error. "+estr).c_str()){}
virtual ~logic_error(){}
//virtual ~logic_error(){}
};
class domain_error : public std::domain_error
@ -155,7 +155,7 @@ namespace gctl
public:
domain_error() : std::domain_error("GCTL: Domain error."){}
domain_error(std::string estr) : std::domain_error(("GCTL: Domain error. "+estr).c_str()){}
virtual ~domain_error(){}
//virtual ~domain_error(){}
};
class invalid_argument : public std::invalid_argument
@ -163,7 +163,7 @@ namespace gctl
public:
invalid_argument() : std::invalid_argument("GCTL: Invalid argument."){}
invalid_argument(std::string estr) : std::invalid_argument(("GCTL: Invalid argument. "+estr).c_str()){}
virtual ~invalid_argument(){}
//virtual ~invalid_argument(){}
};
class length_error : public std::length_error
@ -171,7 +171,7 @@ namespace gctl
public:
length_error() : std::length_error("GCTL: Length error."){}
length_error(std::string estr) : std::length_error(("GCTL: Length error. "+estr).c_str()){}
virtual ~length_error(){}
//virtual ~length_error(){}
};
class out_of_range : public std::out_of_range
@ -179,7 +179,7 @@ namespace gctl
public:
out_of_range() : std::out_of_range("GCTL: Out of range."){}
out_of_range(std::string estr) : std::out_of_range(("GCTL: Out of range. "+estr).c_str()){}
virtual ~out_of_range(){}
//virtual ~out_of_range(){}
};
}