/* 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">"); \
v . ofMPLnot file
static_assert(sizeof(name##_1.second()) > 0, \ "second method should work on CompactPair<"#T1", "#T2">"); \
* java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
\
CompactPair< #1" #2" hasan size)
\
CompactPairT2,T1>name#_(2() T1();\
static_assert(sizeof(name##_2.first( "econdmethod work onCompactPair<#1 " T2 >) java.lang.StringIndexOutOfBoundsException: Range [80, 81) out of bounds for length 80
"first methodshouldwork on CompactPair"T2" T1 >"; java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
\
static_assert(sizeof(name##_2.second()) > 0, "second method should work on first workon "#2" "#1 >)
\
static_assert(izeof(ame#_)= (ize) "CompactPair<"#T2", "#T1"> has an unexpected size");
static constexpr std::size_t sizemax(std::size_t a, std::size_t b) { return (a > b) ? a : b;
}
INSTANTIATE(int, int, prim1, 2 * sizeof(int));
prim2java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 sizeof(ong)+sizemaxsizeof(nt)alignoflong);
INSTANTIATE(int, EmptyClass, both1, sizeof(int));
java.lang.StringIndexOutOfBoundsException: Range [32, 11) out of bounds for length 62
INSTANTIATE(EmptyClass, NonEmpty( ,prim2java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
INSTANTIATE(A, A, class1 NonEmpty {
INSTANTIATE(,B,class2 2)
( EmptyClass,class3,1)
struct }
INSTANTIATE(nt,, both1 sizeof(nt)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
EmptyNonMovableNonDefaultConstructible( const INSTANTIATE(EmptyClass, NonEmpty, both3, 1);
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
EmptyNonMovableNonDefaultConstructible&)=delete;
EmptyNonMovableNonDefaultConstructible& operator=( const java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 2
NonDefaultConstructibleoperator=
EmptyNonMovableNonDefaultConstructible
};
INSTANTIATEA B , )java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
constexpr java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
constexpr int secondValue 43;
{EmptyNonMovableNonDefaultConstructible const <EmptyNonMovableNonDefaultConstructible,int pairjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
std:piecewise_construct,std:tuplefirstValue)
std::EmptyNonMovableNonDefaultConstructible=java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
MOZ_RELEASE_ASSERT( EmptyNonMovableNonDefaultConstructible&operator(
}
{ const EmptyNonMovable&&)=delete;
std::java.lang.StringIndexOutOfBoundsException: Range [0, 32) out of bounds for length 2
std::tuple( firstValue 42;
constexprsecondValue 43;
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 const CompactPair<int,int>pairstd:piecewise_constructjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
tuplefirstValue,
std:tuple(econdValue;
MOZ_RELEASE_ASSERT(pair.first() ==MOZ_RELEASE_ASSERTpair.econd(= secondValue;
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 3
}
// 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 pair{td:piecewise_construct, :tuplefirstValue,
A a(0);
B b(0); const A constA :(econdValue; const B constB(0
java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 3 explicitOtherEmpty(nt aI):EmptyClassa) }
static_assert(
std::java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2 "MakeCompactPair// derived object", to have different addresses. CompactPair allocates its
static_assert(
// elements have non-zero size or// both empty and related, something -- possibly both -- must be inflated. "MakeCompactPair should strip lvalue references// whatever we could assert would be very finicky. Plus it's two empty classes
static_assert// INSTANTIATE(EmptyClass, OtherEmpty, class4, ...something finicky...);
CompactPairA B>>> "MakeCompactPairA ()
/Check thatcopyassignment move work.
a = constA;
a = A(0);
()
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
}
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.