Welcome

SweSTHLM1

StockholmCpp 0x2F

berotec event

Today’s sponsor

 

berotec logo

C++ news

 

C++ news

 

St. Louise Meeting ahead (N4966)

Many papers, see

at least 4 papers from Swedish members

TK611/AG09

 

  • Monthly meetings continue

  • Paper-club continues

Recent paper-club

 

Finally!
We did it !!

operator .()

 

Promising paper available
Author will come to speak about it

Next paper-club

 

St. Louise trip report end of August

SwedenCpp

StockholmCpp Planning 2024

 

  • 22nd August

  • End Sept/ begin October

  • late November

Call for Papers

Submit your ideas and suggestions

needyou

Tell us what you want to hear or want to do

Call for Participation

whowants

Quiz time

JetBrainsLicense

The problem

 

template<typename T>
T add(T a, T b) {
    return a + b;
}

// error deduced conflicting types for parameter 'T'
// ('double' and 'int')
auto r = add(2.1, 5);

// works, but not very nice
auto r = add<double>(2.1, 5);

We want

 

template<typename T>
T add(T a, T b) {
    return a + b;
}
// This to just work
auto r = add(2.1, 5);
auto epsilon = std::numeric_limits<double>::epsilon();
assert(std::abs(r - 7.1) < epsilon);

Question

What is ????_??????????

template<typename T>
T add(T a, std::????_??????????<T> b) {
    return a + b;
}

auto r = add(2.1, 5);
auto epsilon = std::numeric_limits<double>::epsilon();
assert(std::abs(r - 7.1) < epsilon);

Answer

 

template<typename T>
T add(T a, std::type_identity_t<T> b) {
    return a + b;
}

auto r = add(2.1, 5);
auto epsilon = std::numeric_limits<double>::epsilon();
assert(std::abs(r - 7.1) < epsilon);

Identity Function

 

\$f(x) = x, \ \forall x \in X\$

or

\$\i\d_X\$

 

Not just for values but also for types

Today’s program

 

  • Arvid: 20 years of libtorrent 🎉

  • 🍹 🍕 Mingle 🍕 🍻

  • Björn: Cache friendly data + functional + ranges = ❤️

Väl mött!