/**
This file is a part of rexy's general purpose library
Copyright (C) 2020 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#ifndef REXY_EXPRESSION_HPP
#define REXY_EXPRESSION_HPP
#include
#include //forward
#include "rexy.hpp"
namespace rexy{
template
class binary_expression
{
static_assert(!std::is_same,void>::value, "Left value of rexy::binary_expression cannot be void!");
static_assert(!std::is_same,void>::value, "Right value of rexy::binary_expression cannot be void!");
public:
using left_type = std::conditional_t::value,
std::remove_reference_t,
L>;
using right_type = std::conditional_t::value,
std::remove_reference_t,
R>;
using left_reference = std::remove_reference_t&;
using left_const_reference = const std::remove_reference_t&;
using right_reference = std::remove_reference_t&;
using right_const_reference = const std::remove_reference_t&;
protected:
left_type m_l;
right_type m_r;
public:
template
constexpr binary_expression(U&& u, V&& v)noexcept:
m_l(std::forward(u)),
m_r(std::forward(v)){}
constexpr binary_expression(const binary_expression&) = default;
constexpr binary_expression(binary_expression&&) = default;
constexpr binary_expression& operator=(const binary_expression&) = default;
constexpr binary_expression& operator=(binary_expression&&) = default;
constexpr left_reference left(void)noexcept{
return m_l;
}
constexpr left_const_reference left(void)const noexcept{
return m_l;
}
constexpr right_reference right(void)noexcept{
return m_r;
}
constexpr right_const_reference right(void)const noexcept{
return m_r;
}
};
template
class unary_expression
{
static_assert(!std::is_same,void>::value, "Value of rexy::unary_expression cannot be void!");
public:
using left_type = std::conditional_t::value,
std::remove_reference_t,
L>;
using left_reference = std::remove_reference_t&;
using left_const_reference = const std::remove_reference_t&;
using value_type = left_type;
using reference = left_reference;
using const_reference = left_const_reference;
protected:
value_type m_l;
public:
template
constexpr unary_expression(U&& u)noexcept:
m_l(std::forward(u)){}
constexpr unary_expression(const unary_expression&)noexcept = default;
constexpr unary_expression(unary_expression&&)noexcept = default;
constexpr reference left(void)noexcept{
return m_l;
}
constexpr const_reference left(void)const noexcept{
return m_l;
}
};
}
#endif