Cover fe ature 47 january 2012 Published by the ieee computer Society 0018-9162/12/$31. 00 2012 ieee


Relying heavily on runtime resolution



Download 1,78 Mb.
Pdf ko'rish
bet19/32
Sana13.01.2022
Hajmi1,78 Mb.
#355100
1   ...   15   16   17   18   19   20   21   22   ...   32
Bog'liq
Software-for-infrastructure

Relying heavily on runtime resolution 

or interpretation does not provide the 

maintainability and efficiency needed 

for infrastructure.


COVER FE ATURE

compUteR

 

54

generic code optimized for particular hardware through 

parameters). For example,

template

typename Container::iterator

find_if(Container& c, Predicate pred)

     // return an iterator to the first element in c

     // for which pred(element) is true

{

      auto p = c.begin();

      while(p!=c.end() && !pred(*p)) ++p;

      return p;

}

void user (vector& v,

    list& lst,

    Date threshold)

{

      auto p = find_if(v,

               [](const string& s)

                       { return s<”Fulcrum”; }

         );

      // …

      auto q = find_if(lst,

              [](const Record* p)

                      { return threshold
date; }


)

 

// …

}

Here, the generic function 



find_if()

 is called with 

dramatically different arguments: a 

vector

 of 


strings

and a 



list

 of pointers to 



Records

. The search criteria are 

presented as lambda expressions. Every modern C++   

compiler can generate code for this that equals or outper-

forms elaborate hand-coded alternative implementations.

10

 



Note the way that code from different sources is used to 

compose the solution:

 



the 



list



vector

, and 

string

 from the ISO C++ stan-

dard library;

 



the

 find_if()

 and 


Record

 from my application; and

 



the lambda expressions written specifically in 



user().

There’s no need for “glue code,” use of inheritance, wrap-

ping of built-in types (such as 

Record*

) into self-describing 

objects, or dynamic resolution. This style of generic code 

is often called STL-style.

11

However, the interfaces are still underspecified—in 



Download 1,78 Mb.

Do'stlaringiz bilan baham:
1   ...   15   16   17   18   19   20   21   22   ...   32




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish