String::String(const String &s) { auto ret = alloc_n_copy(s.begin(),s.end()); spos = ret.first ; first_free = epos = ret.second ; cout << "executing String(String) " << endl; }
String::String(const String& str) { auto newdata = alloc_n_copy(str.begin(), str.end()); elements = newdata.first; firstfree = cap = newdata.second; std::cout << "copy construct" << std::endl; }
StrVec &StrVec::operator=(const StrVec &rhs) { auto data = alloc_n_copy(rhs.begin(), rhs.end()); free(); first_elem = data.first; first_free = cap = data.second; return *this; }
String::String(const String& s) { std::cout << "copy constructor used" << std::endl; auto data = alloc_n_copy(s.begin(), s.end()); elements = data.first; first_free = data.second; }
str_vec &str_vec::operator=(const str_vec &vc) { auto p = alloc_n_copy(vc.elements,vc.first_free); free(); elements = p.first; first_free = cap = p.second; return *this; }
String& String::operator=(const String &rhs) { std::cout << "operator=(const String&)" << std::endl; auto newStr = alloc_n_copy(rhs.cStringBegin, rhs.cStringEnd); free(); cStringBegin = newStr.first; cStringEnd = newStr.second; return *this; }
String::String(const char* begin) { int length = strlen(begin); char* end = const_cast<char*>(begin)+length+1; auto data = alloc_n_copy(begin, end); elements = data.first; firstfree = cap = data.second; }
StrVec::StrVec(const StrVec& orig) { // call alloc_n_copy to allocate space and copy data auto newData = alloc_n_copy(orig.begin(), orig.end()); // update pointers elements = newData.first; first_free = cap = newData.second; }
String& String::operator = (const String &rhs) { auto newstr = alloc_n_copy(rhs.elements, rhs.end); free(); elements = newstr.first; end = newstr.second; return *this; }
StrVec & StrVec::operator=(const StrVec &sv) { free(); auto ret = alloc_n_copy(sv.begin(),sv.end()); elements = ret.first; first_free = cap =ret.second ; return *this; }
String & String::operator= (const String &s) { free(); auto ret = alloc_n_copy(s.begin(),s.end()); spos = ret.first ; first_free = epos = ret.second ; cout << "executing operator = " << endl ; return *this; }
String& String::operator=(const String& rhs) { auto newstr = alloc_n_copy(rhs.elements, rhs.end); free(); elements = newstr.first; end = newstr.second; std::cout << "copy-assignment" << std::endl; return *this; }
String& String::operator=(String& str) { auto newdata = alloc_n_copy(str.begin(), str.end()); free(); elements = newdata.first; firstfree = cap = newdata.second; std::cout << "Operator=" << std::endl; return *this; }
String& String:: operator=(const String& rhs) { std::cout << "copy assignment operator used" << std::endl; auto data = alloc_n_copy(rhs.begin(), rhs.end()); free(); elements = data.first; first_free = data.second; return *this; }
StrVec& StrVec::operator=(const StrVec& rhs) { // call alloc_n_copy to allocate space and copy data auto newData = alloc_n_copy(rhs.begin(), rhs.end()); // first, free the old memory free(); //update pointers elements = newData.first; first_free = cap = newData.second; return *this; }
//! copy constructor StrVec::StrVec(const StrVec &s) { /** * @brief newData is a pair of pointers pointing to newly allocated and copied * range : [b, e) */ std::pair<std::string*, std::string*> newData = alloc_n_copy(s.begin(), s.end()); element = newData.first; first_free = cap = newData.second; }
//! operator = StrVec& StrVec::operator =(const StrVec& rhs) { //! allocate and copy first to protect against self-assignment std::pair<std::string*, std::string*> newData = alloc_n_copy(rhs.begin(), rhs.end()); //! destroy and deallocate free(); element = newData.first; first_free = cap = newData.second; return *this; }
String::String(const char *s) { auto ret = alloc_n_copy(s,s + strlen(s)); spos = ret.first ; first_free = epos = ret.second ; }
void String::range_initializer(const char* first, const char* last) { auto newstr = alloc_n_copy(first, last); elements = newstr.first; end = newstr.second; }
StrVec::StrVec(const StrVec &rhs) { auto data = alloc_n_copy(rhs.begin(), rhs.end()); first_elem = data.first; first_free = cap = data.second; }
StrVec::StrVec(const StrVec &rhs) { auto newdata = alloc_n_copy(rhs.begin(), rhs.end()); elements = newdata.first; first_free = cap = newdata.second; }
StrVec::StrVec(const initializer_list<string> il) { auto newData = alloc_n_copy(il.begin(), il.end()); elements = newData.first; first_free = cap = newData.second; }
str_vec::str_vec(const std::initializer_list<std::string> &s) { auto r = alloc_n_copy((std::string *)s.begin(),(std::string *)s.end()); elements = r.first; cap = first_free = r.second; }
str_vec::str_vec(const str_vec &vc) { auto p = alloc_n_copy(vc.elements,vc.first_free); elements = p.first; cap = first_free = p.second; }
StrVec::StrVec(initializer_list<string> s) { auto ret = alloc_n_copy(s.begin(),s.end()); elements = ret.first ; first_free = cap = ret.second ; }
StrVec::StrVec(const StrVec &sv) { auto ret = alloc_n_copy(sv.begin(),sv.end()); elements = ret.first; first_free = cap = ret.second; }
void StrVec::range_initialize(const std::string* first, const std::string* last) { auto newdata = alloc_n_copy(first, last); elements = newdata.first; first_free = cap = newdata.second; }
void String::range_initializer(const char *begin, const char *end) { auto newStr = alloc_n_copy(begin, end); cStringBegin = newStr.first; cStringEnd = newStr.second; }