cleanup configflags to use uint instead of char

using char for those flag template parameters
was never a good idea. It won't save us any space
and makes debugging harder
This commit is contained in:
Fischlurch 2011-12-03 03:14:25 +01:00
parent d9f84a9bfd
commit 7fd28e23eb
4 changed files with 40 additions and 39 deletions

View file

@ -58,15 +58,15 @@ namespace meta{
const size_t CONFIG_FLAGS_MAX = 5;
template<char bit> struct Flag { typedef Flag ID; };
template<uint bit> struct Flag { typedef Flag ID; };
template<> struct Flag<0> { typedef NullType ID; };
template< char f1=0
, char f2=0
, char f3=0
, char f4=0
, char f5=0
template< uint f1=0
, uint f2=0
, uint f3=0
, uint f4=0
, uint f5=0
>
struct Flags
{
@ -81,11 +81,11 @@ namespace meta{
};
template< char f1=0
, char f2=0
, char f3=0
, char f4=0
, char f5=0
template< uint f1=0
, uint f2=0
, uint f3=0
, uint f4=0
, uint f5=0
>
struct Config ///< distinct type representing a configuration
{
@ -95,15 +95,15 @@ namespace meta{
template<char Fl, class CONF>
template<uint Fl, class CONF>
struct ConfigSetFlag; ///< set (prepend) the Flag to the given config
template< char Fl
, char f1
, char f2
, char f3
, char f4
, char IGN
template< uint Fl
, uint f1
, uint f2
, uint f3
, uint f4
, uint IGN
>
struct ConfigSetFlag<Fl, Config<f1,f2,f3,f4,IGN> >
{
@ -119,7 +119,7 @@ namespace meta{
typedef CONF Config;
typedef Config Type;
};
template<char Fl, class FLAGS, class CONF>
template<uint Fl, class FLAGS, class CONF>
struct BuildConfigFromFlags< Node<Flag<Fl>,FLAGS>, CONF>
{
typedef typename ConfigSetFlag< Fl
@ -134,8 +134,8 @@ namespace meta{
namespace {
/** helper comparing enum values and chars (flags) */
template<char ii, char jj>
/** helper comparing enum values and flags */
template<uint ii, uint jj>
struct maxC
{
enum{ VAL = ii < jj? jj : ii };
@ -157,7 +157,7 @@ namespace meta{
template<class FLAGS>
struct FlagInfo;
template<char ff, class FLAGS>
template<uint ff, class FLAGS>
struct FlagInfo<Node<Flag<ff>, FLAGS> >
{
enum{ BITS = maxC< ff, FlagInfo<FLAGS>::BITS> ::VAL

View file

@ -282,7 +282,7 @@ namespace config {
///////////////////////////: but BufferProvider selection is going to be solved differently anyway, see Ticket #249
template<class CONF>
struct SelectBuffProvider { typedef AllocBufferFromParent Type; };
template<char PROC_ign, char INPLA_ign>
template<uint PROC_ign, uint INPLA_ign>
struct SelectBuffProvider< Config<CACHING, PROC_ign, INPLA_ign> > { typedef AllocBufferFromCache Type; };
@ -290,7 +290,7 @@ namespace config {
struct Strategy ;
template<char INPLACE_ign>
template<uint INPLACE_ign>
struct Strategy< Config<CACHING,PROCESS,INPLACE_ign> >
: QueryCache<
AllocBufferTable<
@ -302,7 +302,7 @@ namespace config {
OperationBase > > > > > > >
{ };
template<char INPLACE_ign>
template<uint INPLACE_ign>
struct Strategy< Config<PROCESS,INPLACE_ign> >
: AllocBufferTable<
PullInput<

View file

@ -102,7 +102,7 @@ namespace test {
template<> struct Maybe<Conf1> : Indeed { enum{ CODE = 10 }; };
template<> struct Maybe<Conf3> : Indeed { enum{ CODE = 30 }; };
template<char Fl>
template<uint Fl>
struct Maybe<Config<TWO,Fl> >
{
typedef Yes_t is_defined;

View file

@ -22,6 +22,7 @@
/** @file typelist-diagnostics.hpp
** Support for writing metaprogramming unit-tests dealing with typelists and flags.
** a Printer template usable for debugging the structure of a typelist built
** upon some simple debugging-style types. Examples being a Num<int> template,
** or the Flag type. A Printer type generated from this template provides
@ -58,9 +59,9 @@ namespace meta {
/** dummy interface / baseclass for diagnostics */
struct Numz
{
char o_;
Numz (char x =0) : o_(x) { }
operator char () const { return o_; }
uint o_;
Numz (uint x =0) : o_(x) { }
operator uint () const { return o_; }
};
@ -72,18 +73,18 @@ namespace meta {
{
enum{ VAL=I };
Num (char x = char(I)) : Numz(x) { }
Num (uint x = uint(I)) : Numz(x) { }
};
/* some forwards used by config-flags-test.cpp */
template<char bit> struct Flag;
template< char f1
, char f2
, char f3
, char f4
, char f5
template<uint bit> struct Flag;
template< uint f1
, uint f2
, uint f3
, uint f4
, uint f5
>
struct Config;
@ -97,7 +98,7 @@ namespace meta {
namespace test { //< unit tests covering typelist manipulating templates
namespace test { // unit tests covering typelist manipulating templates
namespace { // hidden internals for diagnostics....
using boost::format;
@ -129,7 +130,7 @@ namespace meta {
static string print () { return str( fmt % uint(Num<I>::VAL) % BASE::print()); }
};
template<class BASE, char Fl>
template<class BASE, uint Fl>
struct Printer<Flag<Fl>, BASE> ///< display the presence of a Flag in the typelist
: BASE
{
@ -168,7 +169,7 @@ namespace meta {
}
};
template<char f1, char f2, char f3, char f4, char f5, class BASE>
template<uint f1, uint f2, uint f3, uint f4, uint f5, class BASE>
struct Printer<Config<f1,f2,f3,f4,f5>, BASE>
: BASE
{