Select Git revision
-
Stepan Salenikovich authored
Use the same make -j argument when building lrc and client as when building the daemon. lrc builds much faster this way. Change-Id: Ifaecdaeb86e4bc9862004ca880eddaaa8d91dc98
Stepan Salenikovich authoredUse the same make -j argument when building lrc and client as when building the daemon. lrc builds much faster this way. Change-Id: Ifaecdaeb86e4bc9862004ca880eddaaa8d91dc98
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
enumclass_utils.h 8.55 KiB
/*
* Copyright (C) 2014-2015 Savoir-Faire Linux Inc.
*
* Author: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef ENUM_CLASS_UTILS_H
#define ENUM_CLASS_UTILS_H
#include <map>
#include "logger.h"
#include <type_traits>
#include <vector>
#include <cassert>
namespace ring {
/**
* This function adds a safe way to get an enum class size
* @note it cannot be unsigned to avoid some compiler warnings
*/
template<typename A> constexpr inline int enum_class_size() {
return size_t(A::COUNT__);
}
/**
* This generic class represents a multidimensional enum class array.
* It safely converts them to integers. Each enum class needs a "COUNT__" item
* at the end."
*
* This struct enforces:
* * That the rows are indexed using enum_classes
* * That the size of the matrix matches the enum_class size
* * That the operators are within the matrix boundary
*/
template<class Row, typename Value, typename A = Value>
struct Matrix1D
{
Matrix1D(std::initializer_list< std::initializer_list<Value> > s);
// Row is a built-in type ("int" by default)
Value operator[](Row v);
const Value operator[](Row v) const;
/**
* An Iterator for enum classes
*/
class EnumClassIter
{
public:
EnumClassIter (const Matrix1D<Row, Value, A>* p_vec, int pos)
: pos_( pos ), p_vec_( p_vec ) {}
bool operator!= (const EnumClassIter& other) const;