get rid of some unnecessary code

* spot/priv/enumflags.hh: Delete.
* spot/priv/Makefile.am, debian/copyright: Adjust.
* spot/twaalgos/remfin.cc: Replace the complex enum
definition by a plain enum that is almost not used.
This commit is contained in:
Alexandre Duret-Lutz 2017-09-01 20:58:35 +02:00
parent 15cc7301cc
commit cd6f1c2c3e
4 changed files with 12 additions and 148 deletions

View file

@ -1,6 +1,6 @@
## -*- coding: utf-8 -*-
## Copyright (C) 2013, 2014, 2015, 2016 Laboratoire de Recherche et
## Développement de l'Epita (LRDE).
## Copyright (C) 2013, 2014, 2015, 2016, 2017 Laboratoire de Recherche
## et Développement de l'Epita (LRDE).
##
## This file is part of Spot, a model checking library.
##
@ -25,7 +25,6 @@ libpriv_la_SOURCES = \
accmap.hh \
bddalloc.cc \
bddalloc.hh \
enumflags.hh \
freelist.cc \
freelist.hh \
satcommon.hh\

View file

@ -1,117 +0,0 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2006, 2014 Petr Ročkai <me@mornfall.net>
// Copyright (C) 2013-2015 Vladimír Štill <xstill@fi.muni.cz>
// Copyright (C) 2017 Henrich Lauko <xlauko@mail.muni.cz>
//
// This file is a modification of brick-types file from brick library.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#pragma once
#include <type_traits>
namespace spot
{
template<typename E>
using is_enum_class = std::integral_constant<bool,
std::is_enum<E>::value && !std::is_convertible<E, int>::value>;
template<typename self>
struct strong_enum_flags {
static_assert(is_enum_class<self>::value, "Not an enum class.");
using type = strong_enum_flags<self>;
using underlying_type = typename std::underlying_type<self>::type;
constexpr strong_enum_flags() noexcept : store(0) {}
constexpr strong_enum_flags(self flag) noexcept :
store(static_cast<underlying_type>(flag))
{}
explicit constexpr strong_enum_flags(underlying_type st) noexcept
: store(st) {}
constexpr explicit operator underlying_type() const noexcept
{
return store;
}
type &operator|=(type o) noexcept
{
store |= o.store;
return *this;
}
type &operator&=(type o) noexcept
{
store &= o.store;
return *this;
}
type &operator^=(type o) noexcept
{
store ^= o.store;
return *this;
}
friend constexpr type operator~(type a)
{
return type(~a.store);
}
friend constexpr type operator|(type a, type b) noexcept
{
return type(a.store | b.store);
}
friend constexpr type operator&(type a, type b) noexcept
{
return type(a.store & b.store);
}
friend constexpr type operator^(type a, type b) noexcept
{
return type(a.store ^ b.store);
}
friend constexpr bool operator==(type a, type b) noexcept
{
return a.store == b.store;
}
friend constexpr bool operator!=(type a, type b) noexcept
{
return a.store != b.store;
}
constexpr bool has(self x) const noexcept
{
return ((*this) &x);
}
type clear(self x) noexcept
{
store &= ~underlying_type(x);
return *this;
}
explicit constexpr operator bool() const noexcept
{
return store;
}
private:
underlying_type store;
};
}

View file

@ -25,7 +25,6 @@
#include <spot/twaalgos/isdet.hh>
#include <spot/twaalgos/mask.hh>
#include <spot/twaalgos/alternation.hh>
#include "spot/priv/enumflags.hh"
// #define TRACE
#ifdef TRACE
@ -38,21 +37,20 @@ namespace spot
{
namespace
{
enum class strategy_t : unsigned
enum strategy_t
{
trivial = 1,
weak = 2,
alternation = 4,
rabin = 8,
streett = 16,
trivial = 1U,
weak = 2U,
alternation = 4U,
rabin = 8U,
streett = 16U,
};
using strategy_flags = strong_enum_flags<strategy_t>;
using strategy =
std::function<twa_graph_ptr(const const_twa_graph_ptr& aut)>;
twa_graph_ptr
remove_fin_impl(const const_twa_graph_ptr&, const strategy_flags);
remove_fin_impl(const const_twa_graph_ptr&, const strategy_t);
using EdgeMask = std::vector<bool>;
@ -759,11 +757,11 @@ namespace spot
}
twa_graph_ptr remove_fin_impl(const const_twa_graph_ptr& aut,
const strategy_flags skip = {})
const strategy_t skip = {})
{
auto handle = [&](strategy stra, strategy_t type)
auto handle = [&](strategy stra, strategy_t type) -> twa_graph_ptr
{
return (type & ~skip) ? stra(aut) : nullptr;
return (type & skip) ? nullptr : stra(aut);
};
if (auto maybe = handle(trivial_strategy, strategy_t::trivial))