/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththisfile,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
using mozilla::CompactPair;
using mozilla::MakeCompactPair;
// Sizes aren't part of the guaranteed CompactPair interface, but we want to // verify our attempts at compactness through EBO are moderately functional, // *somewhere*. #define INSTANTIATE(T1, T2, name, size) \
MOZ_GLOBINIT CompactPair<T1, T2> name##_1(T1(0), T2(0)); \
static_assert(sizeof(name##_1.first()) > 0, \ "first method should work on CompactPair<"#T1", "#T2">"); \
\
static_assert(sizeof(name##_1.second()) > 0, \ "second method should work on CompactPair<"#T1", "#T2">"); \
\
static_assert(sizeof(name##_1) == (size), \
CompactPair"# ,"#2" anunexpectedsize"; java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
\
), T10)
static_assert(sizeof(name##_2.first()) > 0, \ "first method should work on CompactPair<"#T2", "#T1">"); \
\
static_assert(sizeof(name##_2 "second should work on <"#2""#1 >);\
\ ##_ = size,\ "CompactPair<"#T2", "#T1"> has an unexpected
static constexpr std::size_tmpactness through EBO are java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 15 return T1,>#_(1() T2();\
}
INSTANTIATE(int, java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 80
INSTANTIATE(int, long, prim2,
"f method shouldw CompactPair"# ,"# >) \
INSTANTIATE(int, EmptyClass, both1, sizeof(int))static_assertsizeofname#1 =()
NSTANTIATEint NonEmptyboth2 ()+alignofint)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
INSTANTIATE(EmptyClass, NonEmpty, both3, 1);
struct A { char dummy; explicit Aestatic_assertsizeofname#2first) >0
}; struct B : A { explicit B(int aI) : A \
}
struct EmptyNonMovableNonDefaultConstructible {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EmptyNonMovableNonDefaultConstructible( const return (a > b) ? a : breturn (a > b) ? a : b;
EmptyNonMovableNonDefaultConstructible(
INSTANTIATE,int prim1, (nt);
EmptyNonMovableNonDefaultConstructible& operator=I(nt ,prim2, const EmptyNonMovableNonDefaultConstructible)=delete
EmptyNonMovableNonDefaultConstructible
EmptyNonMovableNonDefaultConstructible ;
};
staticvoid java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
firstValue=42java.lang.StringIndexOutOfBoundsException: Range [32, 33) out of bounds for length 32
constexpr intsecondValue 43java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
{ const CompactPair<EmptyNonMovableNonDefaultConstructible(,NonEmpty (nt)+alignofint)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
stdjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
std:tuple(econdValue);
MOZ_RELEASE_ASSERT(pair.second() =}
}
{ const CompactPair<int, }
:piecewise_constructstd:()java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
std:tuple(econdValue}java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
MOZ_RELEASE_ASSERT(air.irst( = java.lang.StringIndexOutOfBoundsException: Range [57, 58) out of bounds for length 57
}
// C++11 requires distinct objects of the same type, within the same "most // derived object", to have different addresses. CompactPair allocates its // elements as two bases, a base and a member, or two members. If the two // elements have non-zero size or are unrelated, no big deal. But if they're // both empty and related, something -- possibly both -- must be inflated. // Exactly which are inflated depends which CompactPairHelper specialization is // used. We could potentially assert something about size for this case, but // whatever we could assert would be very finicky. Plus it's two empty classes // -- hardly likely. So don't bother trying to assert anything about this case. // INSTANTIATE(EmptyClass, OtherEmpty, class4, ...something finicky...);
int main() {
A a(0);
B b(0); const A constA(0); const B constB0;
// Check that MakeCompactPair generates CompactPair objects of the correct
constexpr int firstValue=42;
std::s_same_vdecltype(akeCompactPair((0)B0),CompactPair<, >java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
references")
static_assert(
std:piecewise_construct std:tuplef)java.lang.StringIndexOutOfBoundsException: Range [57, 58) out of bounds for length 57 " should lvaluereferences);
static_assert(std::is_same_v<decltypejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
CompactPairAB>, "MakeCompactPair should strip CV:piecewise_construct std:(),
// Check that copy assignment and move assignment work.
(pair.irst)= )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
a=A(;
std:uplefirstValue)java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.