/* Copyright (C) 2018 David Robillard Copyright (C) 2006-2007 Chris Hamilton 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 2 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 CHILBERT_OPERATORS_HPP #define CHILBERT_OPERATORS_HPP #include "chilbert/Traits.hpp" #include #include namespace chilbert { template std::enable_if_t, T> operator&(const T& lhs, const T& rhs) { T r{lhs}; r &= rhs; return r; } template std::enable_if_t, T> operator|(const T& lhs, const T& rhs) { T r{lhs}; r |= rhs; return r; } template std::enable_if_t, T> operator^(const T& lhs, const T& rhs) { T r{lhs}; r ^= rhs; return r; } template std::enable_if_t, T> operator~(const T& vec) { T r{vec}; r.flip(); return r; } template std::enable_if_t, T> operator<<(const T& vec, const size_t bits) { T r{vec}; r <<= bits; return r; } template std::enable_if_t, T> operator>>(const T& vec, const size_t bits) { T r{vec}; r >>= bits; return r; } template inline std::enable_if_t, std::ostream>& operator<<(std::ostream& os, const T& vec) { for (size_t i = 0; i < vec.size(); ++i) { os << vec.test(vec.size() - i - 1); } return os; } } // namespace chilbert #endif