diff --git a/libs/main/containers/picontainers.h b/libs/main/containers/picontainers.h index 05891bdd..81c3c1a8 100644 --- a/libs/main/containers/picontainers.h +++ b/libs/main/containers/picontainers.h @@ -165,8 +165,8 @@ template _PIReverseWrapper PIReverseWrap(const C & c) {return _P //! \~russian Порядок обхода для функции изменения размерности reshape(). //! \~ \sa \a PIVector::reshape(), \a PIDeque::reshape() enum ReshapeOrder { - ReshapeByRow, - ReshapeByColumn + ReshapeByRow /*! \~english Traversing elements by line, just as they stay in memory \~russian Обход элементов построчно, так же как они находятся в памяти */, + ReshapeByColumn /*! \~english Traversing elements by column \~russian Обход элементов по столбцам */, }; #endif // PICONTAINERS_H diff --git a/libs/main/containers/pipair.h b/libs/main/containers/pipair.h index eda825bc..8dc066d7 100644 --- a/libs/main/containers/pipair.h +++ b/libs/main/containers/pipair.h @@ -1,8 +1,17 @@ -/*! \file pipair.h - * \brief pair - * - * This file declare PIPair -*/ +//! \addtogroup Containers +//! \{ +//! \file pipair.h +//! \brief +//! \~english Declares \a PIPair +//! \~russian Объявление \a PIPair +//! \~\authors +//! \~english +//! Ivan Pelipenko peri4ko@yandex.ru; +//! Andrey Bychkov work.a.b@yandex.ru; +//! \~russian +//! Иван Пелипенко peri4ko@yandex.ru; +//! Андрей Бычков work.a.b@yandex.ru; +//! \~\} /* PIP - Platform Independent Primitives pair @@ -27,30 +36,88 @@ #include "picout.h" -class PICout; +//! \addtogroup Containers +//! \{ +//! \class PIPair +//! \brief +//! \~english +//! \~russian Класс, который позволяет хранить два разнородных объекта как единое целое. +//! \~\} +//! \details +//! \~english +//! \~russian +//! \~\sa \a PIMap template class PIPair { public: - PIPair() {first = Type0(); second = Type1();} - PIPair(std::tuple tuple) {first = std::get<0>(tuple); second = std::get<1>(tuple);} - PIPair(const Type0 & value0, const Type1 & value1) {first = value0; second = value1;} + PIPair() : first(), second() {} + PIPair(std::tuple tuple) { + first = std::get<0>(tuple); + second = std::get<1>(tuple); + } + PIPair(const Type0 & value0, const Type1 & value1) { + first = value0; + second = value1; + } + PIPair(Type0 && value0, Type1 && value1) { + first = std::move(value0); + second = std::move(value1); + } Type0 first; Type1 second; }; + +//! \~english Compare operator with PIPair. +//! \~russian Оператор сравнения с PIPair. template -inline bool operator <(const PIPair & value0, const PIPair & value1) {return value0.first < value1.first;} +inline bool operator ==(const PIPair & value0, const PIPair & value1) { + return (value0.first == value1.first) && (value0.second == value1.second); +} + +//! \~english Compare operator with PIPair. +//! \~russian Оператор сравнения с PIPair. template -inline bool operator ==(const PIPair & value0, const PIPair & value1) {return (value0.first == value1.first) && (value0.second == value1.second);} -template -inline bool operator !=(const PIPair & value0, const PIPair & value1) {return (value0.first != value1.first) || (value0.second != value1.second);} +inline bool operator !=(const PIPair & value0, const PIPair & value1) { + return (value0.first != value1.first) || (value0.second != value1.second); +} #ifdef PIP_STD_IOSTREAM template -inline std::ostream & operator <<(std::ostream & s, const PIPair & v) {s << "(" << v.first << ", " << v.second << ")"; return s;} +inline std::ostream & operator <<(std::ostream & s, const PIPair & v) { + s << "(" << v.first << ", " << v.second << ")"; + return s; +} #endif template -inline PICout operator <<(PICout s, const PIPair & v) {s.space(); s.setControl(0, true); s << "(" << v.first << ", " << v.second << ")"; s.restoreControl(); return s;} +inline PICout operator <<(PICout s, const PIPair & v) { + s.space(); + s.setControl(0, true); + s << "(" << v.first << ", " << v.second << ")"; + s.restoreControl(); + return s; +} + + +//! \~english Creates \a PIPair object, deducing the target type from the types of arguments. +//! \~russian Создает \a PIPair выводя типы из аргументов. +//! \~\details +//! \~\code +//! auto p = createPIPair(1, 'a'); +//! piCout << p; // (1, a) +//! \endcode +template< class T1, class T2 > +PIPair createPIPair(const T1 & f, const T2 & s) { + return PIPair(f, s); +} + +//! \~english Creates \a PIPair object, deducing the target type from the types of arguments. +//! \~russian Создает \a PIPair выводя типы из аргументов. +//! \sa \a createPIPair() +template< class T1, class T2 > +PIPair createPIPair(T1 && f, T2 && s) { + return PIPair(std::move(f), std::move(s)); +} #endif // PIPAIR_H