pext.hpp
Go to the documentation of this file.
/*
* Copyright 2016-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PMEMOBJ_PEXT_HPP
#define PMEMOBJ_PEXT_HPP
#include "libpmemobj++/p.hpp"
#include <iostream>
#include <limits>
namespace pmem
{
namespace obj
{
template <typename T>
std::ostream &
operator<<(std::ostream &os, const p<T> &pp)
{
return os << pp.get_ro();
}
template <typename T>
std::istream &
operator>>(std::istream &is, p<T> &pp)
{
is >> pp.get_rw();
return is;
}
template <typename T>
p<T> &operator++(p<T> &pp)
{
++(pp.get_rw());
return pp;
}
template <typename T>
p<T> &operator--(p<T> &pp)
{
--(pp.get_rw());
return pp;
}
template <typename T>
p<T> operator++(p<T> &pp, int)
{
p<T> temp = pp;
++pp;
return temp;
}
template <typename T>
p<T> operator--(p<T> &pp, int)
{
p<T> temp = pp;
--pp;
return temp;
}
template <typename T, typename Y>
p<T> &
operator+=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() += rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator+=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() += rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator-=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() -= rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator-=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() -= rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator*=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() *= rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator*=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() *= rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator/=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() /= rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator/=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() /= rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator%=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() %= rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator%=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() %= rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator&=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() &= rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator&=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() &= rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator|=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() |= rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator|=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() |= rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator^=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() ^= rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator^=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() ^= rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator<<=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() = lhs.get_ro() << rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator<<=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() = lhs.get_ro() << rhs;
return lhs;
}
template <typename T, typename Y>
p<T> &
operator>>=(p<T> &lhs, const p<Y> &rhs)
{
lhs.get_rw() = lhs.get_ro() >> rhs.get_ro();
return lhs;
}
template <typename T, typename Y>
p<T> &
operator>>=(p<T> &lhs, const Y &rhs)
{
lhs.get_rw() = lhs.get_ro() >> rhs;
return lhs;
}
} /* namespace obj */
} /* namespace pmem */
namespace std
{
template <typename T>
struct numeric_limits<pmem::obj::p<T>> : public numeric_limits<T> {
static constexpr bool is_specialized = true;
};
} /* namespace std */
#endif /* PMEMOBJ_PEXT_HPP */
pmem::obj::operator+=
p< T > & operator+=(p< T > &lhs, const p< Y > &rhs)
Addition assignment operator overload.
Definition: pext.hpp:119
pmem::obj::operator--
p< T > & operator--(p< T > &pp)
Prefix decrement operator overload.
Definition: pext.hpp:86
pmem::obj::operator/=
p< T > & operator/=(p< T > &lhs, const p< Y > &rhs)
Division assignment operator overload.
Definition: pext.hpp:185
pmem::obj::p::get_rw
T & get_rw()
Retrieves read-write reference of the object.
Definition: p.hpp:141
std
Definition: pext.hpp:338
p.hpp
Resides on pmem property template.
pmem::obj::operator|=
p< T > & operator|=(p< T > &lhs, const p< Y > &rhs)
Bitwise OR assignment operator overload.
Definition: pext.hpp:251
pmem::obj::operator>>
std::istream & operator>>(std::istream &is, p< T > &pp)
Istream operator overload.
Definition: pext.hpp:66
pmem::obj::p::get_ro
const T & get_ro() const noexcept
Retrieves read-only const reference of the object.
Definition: p.hpp:156
pmem::obj::operator &=
p< T > & operator &=(p< T > &lhs, const p< Y > &rhs)
Bitwise AND assignment operator overload.
Definition: pext.hpp:229
pmem::obj::operator-=
p< T > & operator-=(p< T > &lhs, const p< Y > &rhs)
Subtraction assignment operator overload.
Definition: pext.hpp:141
pmem::obj::p
Resides on pmem class.
Definition: p.hpp:64
pmem::obj::operator%=
p< T > & operator%=(p< T > &lhs, const p< Y > &rhs)
Modulo assignment operator overload.
Definition: pext.hpp:207
pmem
Definition: allocator.hpp:48
pmem::obj::operator*=
p< T > & operator*=(p< T > &lhs, const p< Y > &rhs)
Multiplication assignment operator overload.
Definition: pext.hpp:163
pmem::obj::operator++
p< T > & operator++(p< T > &pp)
Prefix increment operator overload.
Definition: pext.hpp:76
pmem::obj::operator>>=
p< T > & operator>>=(p< T > &lhs, const p< Y > &rhs)
Bitwise right shift assignment operator overload.
Definition: pext.hpp:317
pmem::obj::operator^=
p< T > & operator^=(p< T > &lhs, const p< Y > &rhs)
Bitwise XOR assignment operator overload.
Definition: pext.hpp:273