MCPcopy Create free account
hub / github.com/boostorg/hana / main

Function main

example/tutorial/appendix_mpl.cpp:381–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379
380
381int main() {
382using namespace hpl;
383
384//////////////////////////////////////////////////////////////////////////////
385// Misc
386//////////////////////////////////////////////////////////////////////////////
387
388// pair
389{
390 static_assert(std::is_same<first<pair<int, float>>::type, int>{}, "");
391 static_assert(std::is_same<second<pair<int, float>>::type, float>{}, "");
392}
393
394//////////////////////////////////////////////////////////////////////////////
395// Intrinsics
396//////////////////////////////////////////////////////////////////////////////
397
398// at
399{
400 using range = range_c<long,10,50>;
401 static_assert(at<range, int_<0>>::value == 10, "");
402 static_assert(at<range, int_<10>>::value == 20, "");
403 static_assert(at<range, int_<40>>::value == 50, "");
404}
405
406// at_c
407{
408 using range = range_c<long, 10, 50>;
409 static_assert(at_c<range, 0>::value == 10, "");
410 static_assert(at_c<range, 10>::value == 20, "");
411 static_assert(at_c<range, 40>::value == 50, "");
412}
413
414// back
415{
416 using range1 = range_c<int,0,1>;
417 using range2 = range_c<int,0,10>;
418 using range3 = range_c<int,-10,0>;
419 using types = vector<int, char, float>;
420 static_assert(back<range1>::value == 0, "");
421 static_assert(back<range2>::value == 9, "");
422 static_assert(back<range3>::value == -1, "");
423 static_assert(std::is_same<back<types>::type, float>{}, "");
424}
425
426// empty
427{
428 using empty_range = range_c<int,0,0>;
429 using types = vector<long,float,double>;
430 static_assert(empty<empty_range>{}, "");
431 static_assert(!empty<types>{}, "");
432}
433
434// front
435{
436 using types1 = vector<long>;
437 using types2 = vector<int,long>;
438 using types3 = vector<char,int,long>;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected