Changeset View
Changeset View
Standalone View
Standalone View
source/ps/CStr.h
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
Lint: Inaccurate Copyright Year: Inaccurate Copyright Year | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsYear. vladislavbelov: Year. | |||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
* The base class of all strings | * The base class of all strings | ||||
**/ | **/ | ||||
class CStr : public std::tstring | class CStr : public std::tstring | ||||
{ | { | ||||
public: | public: | ||||
using StrBase = std::tstring; | using StrBase = std::tstring; | ||||
using Char = typename std::tstring::value_type; | using Char = typename std::tstring::value_type; | ||||
CStr() {} | |||||
CStr(const Char* str) : StrBase(str) {} | |||||
CStr(const Char* str, size_t len) : StrBase(str, len) {} | |||||
CStr(const StrBase& str) : StrBase(str) {} | CStr(const StrBase& str) : StrBase(str) {} | ||||
vladislavbelovUnsubmitted Not Done Inline ActionsIt seems it's not needed as it's a copy constructor for StrBase. vladislavbelov: It seems it's not needed as it's a copy constructor for `StrBase`. | |||||
phositAuthorUnsubmitted Done Inline ActionsIt does not work without. I don't know why. phosit: It does not work without. I don't know why.
The copy constructor is not inherited... The move… | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsIIRC it was done intentionally by standard to hide copy/move constructors and assignments in that case. Might make sense to add a move constructor to avoid copying when constructing from StrBase (and probably assignments). vladislavbelov: IIRC it was done intentionally by standard to hide copy/move constructors and assignments in… | |||||
phositAuthorUnsubmitted Done Inline ActionsI would not add the move constructor in this diff. It might be used a lot and might break a lot. phosit: I would not add the move constructor in this diff. It might be used a lot and might break a lot. | |||||
template<class InputIterator> | |||||
CStr (InputIterator first, InputIterator last) : StrBase(first, last) {} | // Inherit all base class constructors. | ||||
using StrBase::StrBase; | |||||
/** | /** | ||||
* Repeat: Named constructor, to avoid overload overload. | * Repeat: Named constructor, to avoid overload overload. | ||||
* | * | ||||
* @param const CStr & str reference to another CStr object to be repeated for initialization | * @param const CStr & str reference to another CStr object to be repeated for initialization | ||||
* @param size_t Reps number of times to repeat the initialization | * @param size_t Reps number of times to repeat the initialization | ||||
* @return CStr new CStr object | * @return CStr new CStr object | ||||
**/ | **/ | ||||
▲ Show 20 Lines • Show All 273 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Inaccurate Copyright Year