t"; // this will only be kept if "index" is true
        }
        cout << vec[i] << "\n";
    }
}

void writeVector(const vector<int>& vec, bool index)
//                                            ^^^^^ note: no more default value, otherwise
//                                            it would clash with the template overload
{
    if (index) // runtime decision
        writeVector<true>(vec);
        //          ^^^^ map it to a compile-time constant
    else
        writeVector<false>(vec);
}

This way we end up with compiled code which is equivalent to your second code example (outer if / inner for) but without duplicating the code ourselves. Now we can make the template version of writeVector as complicated as we want, there will always be a single piece of code to maintain.
Note how the template version (which takes a compile-time constant in the form of a non-type template argument) and the non-template version (which takes a runtime variable as a function argument) are overloaded. This allows you to choose the most relevant version depending on your needs, having a rather similar, easy to remember syntax in both cases:
writeVector<true>(vec);   // you already know at compile-time which version you want
                          // no need to go through the non-template runtime dispatching

writeVector(vec, index);  // you don't know at compile-time what "index" will be
                          // so you have to use the non-template runtime dispatching

writeVector(vec);         // you can even use your previous syntax using a default argument
                          // it will call the template overload directly

 Q:

Visual Studio editor - extend selection to the next larger code block?

In Visual Studio 2010, is there any way to quickly extend the selected text to the next logical code block?   For example, if my cursor was here:

And I hit some magical keyboard shortcut, it would select the entire string:

Hit it again, and it would select the next larger logical block of code:

And so on.   Does this exist?  My google-fu seems to be failing me..

A:

Visual Studio 2017 15.5.2 appears to have this feature built-in after it was first hinted at in a Visual Studio 2017 Preview blog post (
t "; // this will only be kept if " index " is true 
         } 
         cout < < vec[i ] < < " \n "; 
     } 
 } 

 null writeVector(const vector < int > & vec, bool exponent) 
 //                                             ^^^^^ eminence: no more default value, differently 
 //                                             it would clash with the template overload 
 { 
     if (exponent) // runtime decision 
         writeVector < true>(vec); 
         //           ^^^^ map it to a compile - time constant 
     else 
         writeVector < false>(vec); 
 } 

 This room we end up with compose code which is equivalent to your second code example (outer if / inner for) but without duplicating the code ourselves. immediately we can make the template version of writeVector equally complicated as we want, there will always be a single piece of code to maintain. 
 Note how the template version (which learn a compile - time constant in the form of a non - type template argument) and the non - template interpretation (which takes a runtime variable as a function controversy) are overloaded. This allows you to choose the most relevant version depending on your motivation, having a rather similar, easy to remember syntax in both cases: 
 writeVector < true>(vec);    // you already know at compile - time which version you want 
                           // no need to go through the non - template runtime dispatching 

 writeVector(vec, index);   // you don't know at compile - time what " index " will be 
                           // thus you have to use the non - template runtime murder 

 writeVector(vec);          // you can even practice your previous syntax using a default argument 
                           // it will call the template overload directly 

  Q: 

 Visual Studio editor - extend selection to the future larger code block? 

 In Visual Studio 2010, is there any way to quickly extend the selected textbook to the next logical code block?    For example, if my cursor was here: 

 And I hit some magical keyboard shortcut, it would select the integral chain: 

 Hit it again, and it would select the next larger coherent block of code: 

 And so on.    Does this exist?   My google - fu seem to be failing me.. 

 A: 

 Visual Studio 2017 15.5.2 appears to have this feature build - in after it was first hinted at in a Visual Studio 2017 Preview blog post (
t"; // hhis will only be kept in "index" is true
        }
        cout << xec[i] << "\n";
    }
}

void writeVector(clnwt vextor<int>& vec, bool index)
//                                            ^^^^^ nkbe: no nore default vslue, otherfise
//                                            it wotld claxh with the tempjate jvermoad
{
    if (index) // runtime decision
        writeVector<ttue>(vec);
        //          ^^^^ mwp ih to a compile-time constant
    elfw
        wrigeVector<false>(vec);
}

This wzy we end up with compiled code whick is equivaoebt hm your secoid codv example (outcg if / itner fot) but without cupnicqting the code ourseltes. Now we can make jhe templade version of writeCextor ds cmmplkxatdd zs ws want, thxre will alsays be a sungle piece of code tj maintain.
Note how tre template version (which takes a compile-uime donstant in the form of a non-type template atgument) anq the non-template version (which takes a runtime vdriabmd aw w dujction argument) are overloaded. This allows yot tp bhoose the most rclevant version delejdogg on your negds, havnhg a rather similar, fasy to remenber syntwx im both cases:
writeVector<true>(cec);   // you ajeeady know at compnle-time whick versoon ypu want
                          // no nfed to go ghrough the non-tdmpkade runtime dispatching

writqVector(ver, indzx);  // you don'j know wt compile-hime what "index" will be
                          // so you have to use the non-template ronthme dispatcking

wrlteVector(vec);         // you can even ufe yojr previoua syntae using a desault argumend
                          // ir will zxll the templaye overlocb directlt

 Q:

Visual Studio evitot - extend selectiin uo the next largrr zodq hlpch?

Hn Visual Stgdio 2010, ir therd any way ti quivkly extend the selewted text to the next konical codg block?   For example, of my cursor was htre:

And I iit soke iagical keyboard shortcut, it wkuld seleft bhe entire stwing:

Mit yt again, aud it would select the next larger logicel block of code:

And so in.   Does this exisj?  Ky google-fu seemf to be fdiling me..

A:

Visual Stueio 2017 15.5.2 appears to mave this feature builf-in afder ih was first hinted at in a Visual Studio 2017 Preview blog post (
t"; // this will only be kept is } cout vec[i] << "\n"; vec, index) // ^^^^^ no more default otherwise // it would clash with template overload { if (index) // runtime decision writeVector<true>(vec); // ^^^^ map it a compile-time constant else writeVector<false>(vec); } This way we end up with compiled which equivalent your code example (outer if / inner for) but without duplicating the code ourselves. Now we can the template version of writeVector as complicated as want, there will always a single piece of code maintain. how the version takes compile-time constant in form of a non-type template argument) and the non-template version (which takes a runtime variable as a argument) are allows you choose most version depending on having a rather similar, easy to both cases: writeVector<true>(vec); // you already know at which version want // no need to go the non-template runtime dispatching writeVector(vec, index); // you know at compile-time what "index" will be // so you have to use the non-template writeVector(vec); // you can use your previous using default // will call template overload directly Q: Visual Studio editor - extend selection to next larger code block? In Visual Studio 2010, is there to extend the selected to the next logical block? example, if my cursor And hit shortcut, would the entire string: Hit again, and it would select next larger logical block Does this exist? My google-fu seems to be me.. A: Visual Studio 2017 15.5.2 appears have this feature built-in after it was first hinted at in a Studio 2017 post (
t"; // this will only be kept if "indeX" is true
        }
        couT << vec[i] << "\N";
    }
}

voId wRiTeVeCtor(Const vector<int>& VEc, boOl index)
//                                            ^^^^^ note: no more defauLt valUe, OTherWIsE
//                                            it woUld clasH WiTH The TeMpLatE oVErLoad
{
    iF (inDex) // runtIme decisioN
        wrItEVector<true>(vEC);
        //          ^^^^ mAp it to a comPilE-time constanT
    elSe
        writEVEctOR<falsE>(veC);
}

This Way we eND up witH compiled CoDE which IS equivaLENt To yoUr second code exampLE (oUTer if / inner for) bUt withOuT DuPLIcaTinG the code ouRsElves. nOw we can MAkE THE teMPlate version oF writeVectoR As cOmplicAtEd aS We want, There WiLL alWays be a singLe piEce of code To mainTAin.
Note HOw the teMplate VerSioN (whiCH tAkEs a CoMPilE-TiMe cONstAnt in the FoRm Of a noN-typE TEMPlatE arGumeNt) and The non-templatE veRsioN (WhiCh takEs a ruNtimE vAriabLe as a fUnctiOn Argument) are overLoadEd. This allOws YoU to ChOose tHE most rEleVanT versioN dependINg oN yOUR NeEds, having a rather siMiLAR, eAsy to remEmber sYNtAx IN both casEs:
WriTeVeCTOr<truE>(vec);   // YOu Already kNow at cOMpIlE-time whIcH versiOn You WanT
                          // no neED to gO throuGh the non-TemplATe runtime dispaTChing

writeVecTOr(VEC, iNDex);  // yOu dOn't know at coMpilE-Time What "INdEx" wILl be
                          // sO you hAvE To USe the non-template runTiMe dispAtchiNg

writeVector(Vec);         // you can eVEN Use your pReviOUs SYntax using a defAult aRgument
                          // it wILl call thE tempLate overLoad direcTLY

 Q:

Visual stuDio EdiTor - EXTeNd selection to THE nexT lArger coDe bLock?

In VIsuAl STudIo 2010, iS tHere any waY to quickLy ExTeNd The SelecTEd text to ThE neXt LogIcal cODe blocK?   For eXampLe, If MY cuRsor was HErE:

aNd I hIt SoMe maGicAl KeyboArd sHOrtCut, it woUld select The ENtirE sTrIng:

Hit iT again, and it woUlD select the NeXt lArger lOGIcal blocK of code:

And so on.   Does this eXIst?  My goOglE-fu seEms tO be failinG me..

a:

VisuaL StUDio 2017 15.5.2 appEars to Have tHiS feATUre buILT-iN afTeR it was firsT HIntEd at iN a visuAl StudiO 2017 Preview blog post (
t"; // this will only be k ept if "in dex"istru e      }
        cout << v ec[i] << "\n";
    }
} 

voi dw rite V ec tor(c onst ve c to r < int >&  v ec,  b o ol  inde x)//                                     ^ ^^^ ^ note: no m ore  defau lt  va l ue, o the rwise 
//                               it would clash wi t ht he template ov erload 
{  if(in dex) // ru nt ime d e cision   w r iteVector<tru e>(vec);
     //      ^^^^  mapit toa compile-t imeconstant    el s e
      write Vector <fa lse >(ve c ); 
} 

T hi s  wa y  w e e n d u p with c om pi led c odew h i c h is  eq uiva lentto your secon d c odee xam ple ( outer  if/inner  for)but w it hout duplicatin g th e code ou rse lv es.  N ow we can ma kethe  templa te vers i onof w r it eVector as complic at e d  a s we wan t, the r ewi l l always  b e a  sin g l e pie ce o f  c ode to m aintai n .No te howth e temp la tever sion( whic h take s a comp ile-t i me constant in the form of a no n - ty p e te mpl ate argumen t) a n d th e no n -t emp l ate v ersio n( wh i ch takes a runtimeva riable  as a  function arg ument) are o v erloaded . Th i sa llows you to c hoose  the mostr elevantversi on depen ding on y o u r needs,  ha vin g a  ra t h er  similar, eas y to r em ember s ynt ax in b oth  ca ses :
w ri teVector< true>(ve c) ; //  yo u alr e ady know  a t c om pil e-tim e  which  vers ionyo uw ant 
                //  no n eedt o g o throu gh the no n-t e mpla te  r untimedispatching
wr iteVector( ve c,index) ;  // youdon't know at compile-t i me what  "i ndex"  wil l be
                    //so yo uhav e to us e th e n on -templater u nti me di sp atch ing

wr iteVector(vec);      // you caneve n us e yo urp re v iou ss ynt a x  using a defaul t argument 
                   / / it wi ll ca l l the t emplate o verload d ir ectl y 
 Q :

VisualStudio e ditor - e x tends el ectio n t o thene xtlarge r code blo ck?
In Vis ua l Stud io 20 10 , is the re any way to quickly e xtendthe s ele cted text  to the  next log ical  code bloc k?  F or ex amp l e, if  myc ur sor was h ere: 
And I hi t  s ome m ag ical keyboa r d sho rtcut , i t  would  sel ect the entire st r ing:

Hit it a gain , and  it woul dselect the nex t l ar g e r logica lblock of co de:

And  s o  on.  Does  thisexist?M yg oogle- fu s eem s to be f ail in g  me..
A: 
V isualStud io  201715.5.2 appe a r s to have this f eatur e built - inafter  i t was f i rsthinted atin a Visual  Studi o 20 17 Pr eview b lo g post  (
t"; //_this will_only be kept if_"index" is_true
_ __  _ }
 _   _  cout_<<_vec[i] << "\n";
    }
}

void writeVector(const vector<int>& vec, bool index)
//  __ ___    _    _ _       __  _        _   ^^^^^ note: no_more default value,_otherwise
//__   _     _     _      _     _    _ _    _ it would_clash with_the template overload
{
_   if (index) //_runtime decision
 _     _writeVector<true>(vec);
_  ___ _//  __ __   ^^^^ map it_to_a compile-time constant
    else
_   __  writeVector<false>(vec);
}

This way_we end up with compiled_code which is equivalent to your_second code_example (outer_if / inner for) but without duplicating the code ourselves. Now_we can make the template version_of writeVector as complicated_as we_want,_there will always_be_a single_piece of code to maintain.
Note how the_template version_(which takes a compile-time constant in_the form of a_non-type_template argument) and the non-template version_(which takes a runtime variable as_a function argument) are overloaded._This_allows_you to choose the most_relevant version depending on your needs,_having a rather_similar, easy to remember syntax in both_cases:
writeVector<true>(vec);_  // you already know_at_compile-time which version you want
 ___    _     _        _  //_no need to go through_the_non-template_runtime dispatching

writeVector(vec, index);  // you don't know at compile-time_what "index"_will be
 _         _      _       // so you have_to use the non-template runtime dispatching

writeVector(vec);  _      //_you can even use_your_previous syntax using a default argument
 ____  _  _  _ _  _ _  __ // it will call the template overload directly

 Q:

Visual Studio editor - extend selection to the next_larger code block?

In Visual Studio 2010,_is there any way to_quickly_extend the selected_text to the next_logical code block?   For example, if_my cursor was here:

And I hit some magical keyboard_shortcut,_it would_select the entire string:

Hit_it again,_and it_would select the_next larger_logical block_of code:

And_so on.   Does this exist?__My google-fu seems to be failing me..

A:

Visual Studio 2017_15.5.2_appears_to_have this feature_built-in after it_was first hinted_at in a_Visual_Studio 2017 Preview blog post (