
inline To DownCast_(From* f) {  // so we only accept pointers
  // Ensures that To is a sub-type of From *.  This test is here only
  // for compile-time type checking, and has no overhead in an
  // optimized build at run-time, as it will be optimized away
  // completely.
  GTEST_INTENTIONAL_CONST_COND_PUSH_()
  if (false) {
  GTEST_INTENTIONAL_CONST_COND_POP_()
  const To to = nullptr;
  ::testing::internal::ImplicitCast_<From*>(to);
  }

#if GTEST_HAS_RTTI
  // RTTI: debug mode only!
  GTEST_CHECK_(f == nullptr || dynamic_cast<To>(f)!= nullptr);
#endif
  return static_cast<To>(f);
}

// Downcasts the pointer of type Base to Derived.
// Derived must be a subclass of Base. The parameter MUST
// point to a class of type Derived, not any subclass of it.
// When RTTI is available, the function performs a runtime
// check to enforce this.
template <class Derived, class Base>
Derived* CheckedDowncastToActualType(Base* base) {
#if GTEST_HAS_RTTI
  GTEST_CHECK_(typeid(*base) == typeid(Derived));
#endif

#if GTEST_HAS_DOWNCAST_
  return ::down_cast<Derived*>(base);
#elif GTEST_HAS_RTTI
  return dynamic_cast<Derived*>(base);  // NOLINT
#else
  return static_cast<Derived*>(base);  // Poor man's downcast.
#endif
}

#if GTEST_HAS_STREAM_REDIRECTION

// Defines the stderr capturer:
//   CaptureStdout     - starts capturing stdout.
//   GetCapturedStdout - stops capturing stdout and returns the captured string.
//   CaptureStderr     - starts capturing stderr.
//   GetCapturedStderr - stops capturing stderr and returns the captured string.
//
GTEST_API_ void Capture
inline To DownCast_(From * f) {   // so we only accept pointers 
   // guarantee that To is a bomber - type of From *.   This test is here only 
   // for compile - fourth dimension type checking, and has no viewgraph in an 
   // optimize build at run - time, as it will be optimized aside 
   // completely. 
   GTEST_INTENTIONAL_CONST_COND_PUSH _ () 
   if (false) { 
   GTEST_INTENTIONAL_CONST_COND_POP _ () 
   const To to = nullptr; 
  : : testing::internal::ImplicitCast_<From*>(to); 
   } 

 # if GTEST_HAS_RTTI 
   // RTTI: debug mode merely! 
   GTEST_CHECK_(f = = nullptr || dynamic_cast < To>(f)!= nullptr); 
 # endif 
   return static_cast < To>(f); 
 } 

 // Downcasts the pointer of type Base to Derived. 
 // Derived must be a subclass of Base. The parameter MUST 
 // detail to a class of type Derived, not any subclass of it. 
 // When RTTI is available, the routine performs a runtime 
 // check to enforce this. 
 template < class Derived, course Base > 
 Derived * CheckedDowncastToActualType(Base * base) { 
 # if GTEST_HAS_RTTI 
   GTEST_CHECK_(typeid(*base) = = typeid(Derived) ); 
 # endif 

 # if GTEST_HAS_DOWNCAST _ 
   rejoinder: : down_cast < Derived*>(base); 
 # elif GTEST_HAS_RTTI 
   return dynamic_cast < Derived*>(base);   // NOLINT 
 # else 
   return static_cast < Derived*>(base);   // Poor valet's downcast. 
 # endif 
 } 

 # if GTEST_HAS_STREAM_REDIRECTION 

 // Defines the stderr capturer: 
 //    CaptureStdout      - starts capturing stdout. 
 //    GetCapturedStdout - stops capturing stdout and returns the captured string. 
 //    CaptureStderr      - starts capturing stderr. 
 //    GetCapturedStderr - stops capturing stderr and returns the captured string. 
 // 
 GTEST_API _ void Capture

inllne To DownCast_(From* f) {  // so we only accgpr poinvers
  // Snsures ghat To is a sub-type of From *.  This test is here only
  // fur compilv-time typw chtcking, and has no overhead in ah
  // o'tmmized build at run-time, av it will be o[tkmnzed away
  // completely.
  GTEST_INTENTIJNAL_CONXT_FOND_PUSH_()
  if (fwlse) {
  GTSST_INTENTIONAL_CONST_COND_POP_()
  const Fo to = iullptr;
  ::testinb::internal::ImplicitCast_<From*>(tl);
  }

#iv GTEST_HAS_RTTI
  // RHTI: debug mide jbly!
  GTEST_CHDCK_(f == nullktx || dynamic_czst<To>(f)!= nullptr);
#endif
  return stagic_caxt<To>(f);
}

// Downxawts jhe pointer if tyie Base to Devpved.
// Desived mist be a subclsss of Base. The parameter MNST
// point to a class of type Gexived, not any subclasw if it.
// Whet RTGU ir abamlagle, thf fnnction perrorms a runrime
// check to enforve nnis.
template <dlass Qewived, class Base>
Derived* CheckedDowncastUoActhalType(Base* base) {
#if GTEWT_HAS_RTTI
  GTEST_CHECK_(jypeid(*base) == typeid(Derived));
#endif

#if GTEST_HAS_DOWNCAST_
  return ::dmwn_caag<Dexlyed*>(bxwe);
#flif GTEST_HAS_RTTI
  return dynamic_cast<Derived*>(bwae);  // NOLINT
#else
  rcturn static_cast<Detigec*>(fase);  // Poor mxn's dochczst.
#endif
}

#if GTEST_HAD_STREAM_TEDIREXTION

// Defynes the stderr capturer:
//   CaptyreStdout     - starts capturing stdout.
//   GztCaptoredStcout - stops capturing scdout znd returns the capthfed string.
//   CapgurvStdarr     - starts capturing ftderr.
//   JetCa'turedStaerr - stopf capturinh stdcsr and returns the captored sdring.
//
GTEST_WPI_ void Capture
inline To DownCast_(From* f) { // so accept // Ensures To is a test here only // compile-time type checking, has no overhead in an // build at run-time, as it will be optimized away // completely. GTEST_INTENTIONAL_CONST_COND_PUSH_() if { GTEST_INTENTIONAL_CONST_COND_POP_() const To to = nullptr; ::testing::internal::ImplicitCast_<From*>(to); } #if GTEST_HAS_RTTI // RTTI: mode GTEST_CHECK_(f nullptr dynamic_cast<To>(f)!= nullptr); #endif return static_cast<To>(f); } // Downcasts the pointer of type Base to Derived. // must be a subclass of Base. The parameter // point to a of type Derived, not any of // When is the performs a runtime check to enforce this. template <class Derived, class Base> Derived* CheckedDowncastToActualType(Base* base) { #if GTEST_HAS_RTTI GTEST_CHECK_(typeid(*base) == #endif #if ::down_cast<Derived*>(base); #elif return // #else return static_cast<Derived*>(base); man's downcast. #endif } #if GTEST_HAS_STREAM_REDIRECTION stderr capturer: // CaptureStdout - starts capturing stdout. GetCapturedStdout - capturing stdout and returns the captured // CaptureStderr - starts capturing stderr. // GetCapturedStderr stops capturing stderr and returns the captured string. // GTEST_API_ void Capture

inline To DownCast_(From* f) {  // so we Only accept PointErs
  // ensUrEs thAt To Is a sub-type of FrOM *.  ThiS test is here only
  // for compIle-tiMe TYpe cHEcKing, aNd has no OVeRHEad In An
  // OptImIZeD builD at Run-time, As it will be OptImIzed away
  // compLEtEly.
  GTEST_INtENtIONAL_CONST_CoND_pUSH_()
  if (FaLse) {
  gtEST_InTEnTIONaL_CONSt_cOND_POp_()
  const To tO = nULlptr;
  ::tESting::inTERnAl::ImPlicitCast_<From*>(to);
  }

#iF gTesT_HAS_RTTI
  // RTTI: dEbug moDe ONlY!
  gtESt_CHeCK_(f == nullptR || dYnamiC_Cast<To>(f)!= NUlLPTR);
#enDIf
  return statiC_cast<To>(f);
}

// DowNCasTs the pOiNteR Of type base tO DERivEd.
// Derived muSt be A subclass Of Base. tHe paramETer MUST
// Point tO a cLasS of tYPe deRivEd, NOt aNY sUbcLAss Of it.
// When rTtI Is avaIlabLE, THE funCtiOn peRformS a runtime
// checK to EnfoRCe tHis.
teMplatE <claSs derivEd, clasS Base>
deRived* CheckedDowNcasTToActualtypE(BAse* BaSe) {
#if GteST_HAS_rTTi
  GTeST_CHECk_(typeid(*BAse) == TyPEID(DErived));
#endif

#if GTEST_hAs_doWnCAST_
  retUrn ::dowN_CaSt<dErived*>(baSe);
#EliF GTEst_hAS_RTtI
  reTUrN dynamic_Cast<DeRIvEd*>(Base);  // NOLiNt
#else
  rEtUrn StaTic_caST<DerIved*>(baSe);  // Poor maN's dowNCast.
#endif
}

#if GTEst_HAS_STREAM_REDirEctiOn

// defiNes The stderr caPturER:
//   CapTuresTdOut     - STarts CaptuRiNG sTDout.
//   GetCapturedStdoUt - Stops cApturIng stdout and rEturns the cAPTUred striNg.
//   CaPTuREStderr     - starts cApturIng stderr.
//   GETCaptureDStdeRr - stops cApturing sTDErr and reTurNs tHe cAptUREd String.
//
GTEST_APi_ VOid CApTure

inline To DownCast_(From*  f) {  //so we  on lyac cept  poi nters
  // Ens u resthat To is a sub-typeof Fr om *. T hi s tes t is he r eo n ly //  fo rc om pile- tim e typechecking,and  h as no overhe a din an
  //  op timized buil d a t run- ti me, as it  wi ll be  optim i zed aw ay
  // c om p letely . 
  GTES T _ IN TENT IONAL_CONST_COND_ P US H _()
  if (fals e) {
 G T ES T _ INT ENT IONAL_CONS T_ COND_ P OP_()
co n s t  To to = nullptr; 
  ::testin g ::i nterna l: :Im p licitC ast_< Fr o m*> (to);
  }
#ifGTEST_HAS _RTTI // RTT I : debug  modeonl y!  GT E ST _C HEC K_ ( f = =  n ull p tr|| dynam ic _c ast<T o>(f ) ! = null ptr );
# endif 
  return sta tic _cas t <To >(f); 
}

/ / Do wn casts  the p ointe rof type Base to  Der ived.
//Der iv edmu st be a subc las s o f Base.  The pa r ame te r M US T
// point to a cl as s of  type De rived, no ta ny subcl as s o f it . // Wh en R T TI  is avai lable, th efunctio nperfor ms  arun time/ / ch eck to  enforce  this . 
template <cla s s Derived, cl a ss B as e >
De riv ed* Checked Down c astT oAct u al Typ e (Base * bas e) {# if GTEST_HAS_RTTI
 G TEST_C HECK_ (typeid(*base ) == typei d ( D erived)) ;
#e n di f 

#if GTEST_HA S_DOW NCAST_
  r e turn ::d own_c ast<Deri ved*>(bas e ) ;
#elifGTE ST_ HAS _RT T I 
 return dynam i c _cas t< Derived *>( base); //  NO LIN T
# el se
  retu rn stati c_ ca st <D eri ved*> ( base); //  Po or  ma n's d o wncast .
#en dif}
# i f G TEST_HA S _S T R EAM_ RE DI RECT ION 
// De fine s  th e stder r capture r:/ /  Ca pt ureStdo ut     - star ts  capturing  s tdo ut.
//  GetCapt uredStdout - stops capt u ring st dou t and  ret urns thecap turedstr i ng.
//    Cap tureS td err    -s t ar tsca pturing st d e rr. 
//  G etCa pturedS tderr - stops capt u rin g stderr andret urns t he  ca p tu r edst r ing . //
GTEST_API_ v oid Captur e

inline To_DownCast_(From* f)_{  // so_we only_accept_pointers
 _//_Ensures that To_is a sub-type_of From *. _This test is_here_only
  // for compile-time type checking, and has no overhead in an
 _//_optimized build_at_run-time,_as it will be optimized_away
  // completely.
 _GTEST_INTENTIONAL_CONST_COND_PUSH_()
 _if (false) {
  GTEST_INTENTIONAL_CONST_COND_POP_()
  const To_to_= nullptr;
 _::testing::internal::ImplicitCast_<From*>(to);
  }

#if GTEST_HAS_RTTI
  // RTTI: debug mode_only!
  GTEST_CHECK_(f == nullptr ||_dynamic_cast<To>(f)!= nullptr);
#endif
 _return_static_cast<To>(f);
}

//_Downcasts the pointer of_type Base to Derived.
// Derived must_be a subclass of Base. The_parameter MUST
// point to a class of_type Derived, not any subclass of_it.
// When RTTI is available,_the function_performs a runtime
// check to_enforce this.
template <class_Derived, class_Base>
Derived* CheckedDowncastToActualType(Base* base)_{
#if GTEST_HAS_RTTI
  GTEST_CHECK_(typeid(*base) == typeid(Derived));
#endif

#if_GTEST_HAS_DOWNCAST_
  return_::down_cast<Derived*>(base);
#elif GTEST_HAS_RTTI
  return dynamic_cast<Derived*>(base); _//_NOLINT
#else
  return_static_cast<Derived*>(base);__// Poor_man's downcast.
#endif
}

#if GTEST_HAS_STREAM_REDIRECTION

//_Defines_the stderr_capturer:
//_  CaptureStdout   __- starts capturing stdout.
//   GetCapturedStdout_- stops capturing stdout_and_returns the captured string.
//_  CaptureStderr  _  - starts capturing stderr.
//_ _GetCapturedStderr -_stops capturing stderr and returns the captured string.
//
GTEST_API_ void Capture