SERVER-105897ClosedFixed
Make all BSONElement accessors validate that the type is as expected
Currently, {{BSONElement}} accessors do not validate that the type expected by the API matches the actual contents of the referred-to element. Identify a way to add type checking to {{BSONElement}} accessors with an acceptable performance overhead. To maximize chance of success, we can consider it a programmer error to call accessors in a type-mismatched fashion and use {{tassert}} or low-overhead server-aborting mechanisms like {{MONGO_UNREACHABLE}} or {{{}__builtin_trap(){}}}.