bitunion.hh (12454:277c1f58ab6d) bitunion.hh (12465:db848583d43e)
1/*
2 * Copyright (c) 2007-2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 41 unchanged lines hidden (view full) ---

50//function.
51template<class Base>
52class BitfieldTypeImpl : public Base
53{
54 static_assert(std::is_empty<Base>::value,
55 "Bitfield base class must be empty.");
56
57 private:
1/*
2 * Copyright (c) 2007-2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 41 unchanged lines hidden (view full) ---

50//function.
51template<class Base>
52class BitfieldTypeImpl : public Base
53{
54 static_assert(std::is_empty<Base>::value,
55 "Bitfield base class must be empty.");
56
57 private:
58 using Base::setter;
59
58
60 template<typename T>
61 struct TypeDeducer;
59 struct TypeDeducer
60 {
61 template<typename>
62 struct T;
62
63
63 template<typename T>
64 friend class TypeDeducer;
64 template<typename C, typename Type1, typename Type2>
65 struct T<void (C::*)(Type1 &, Type2)>
66 {
67 typedef Type1 Storage;
68 typedef Type2 Type;
69 };
65
70
66 template<typename Type1, typename Type2>
67 struct TypeDeducer<void (Base::*)(Type1 &, Type2)>
68 {
69 typedef Type1 Storage;
70 typedef Type2 Type;
71 struct Wrapper : public Base
72 {
73 using Base::setter;
74 };
75
76 typedef typename T<decltype(&Wrapper::setter)>::Storage Storage;
77 typedef typename T<decltype(&Wrapper::setter)>::Type Type;
71 };
72
73 protected:
78 };
79
80 protected:
74 typedef typename TypeDeducer<
75 decltype(&BitfieldTypeImpl<Base>::setter)>::Storage Storage;
76 typedef typename TypeDeducer<
77 decltype(&BitfieldTypeImpl<Base>::setter)>::Type Type;
81 typedef typename TypeDeducer::Storage Storage;
82 typedef typename TypeDeducer::Type Type;
78
79 Type getter(const Storage &storage) const = delete;
80 void setter(Storage &storage, Type val) = delete;
81
82 Storage __storage;
83
84 operator Type () const
85 {

--- 330 unchanged lines hidden ---
83
84 Type getter(const Storage &storage) const = delete;
85 void setter(Storage &storage, Type val) = delete;
86
87 Storage __storage;
88
89 operator Type () const
90 {

--- 330 unchanged lines hidden ---