1// { dg-options "-std=c++0x" } 2 3struct int_placeholder; 4 5template<typename T> 6struct do_replace 7{ 8 typedef T type; 9}; 10 11template<> 12struct do_replace<int_placeholder> 13{ 14 typedef int type; 15}; 16 17template<typename T> struct lambdalike 18{ 19 typedef T type; 20}; 21 22template<template<typename...> class TT, typename... Args> 23struct lambdalike<TT<Args...> > { 24 typedef TT<typename do_replace<Args>::type...> type; 25}; 26 27 28template<typename T, typename U> 29struct is_same 30{ 31 static const bool value = false; 32}; 33 34template<typename T> 35struct is_same<T, T> 36{ 37 static const bool value = true; 38}; 39 40template<typename... Elements> struct tuple; 41template<typename T1, typename T2> struct pair; 42 43static_assert(is_same<lambdalike<tuple<float, int_placeholder, double>>::type, 44 tuple<float, int, double>>::value, 45 "MPL lambda-like replacement on tuple"); 46static_assert(is_same<lambdalike<pair<float, int_placeholder>>::type, 47 pair<float, int>>::value, 48 "MPL lambda-like replacement on pair"); 49 50 51struct _1 {}; 52 53template<typename Arg0, typename Lambda> 54struct eval 55{ 56 typedef Lambda type; 57}; 58 59template<typename Arg0> 60struct eval<Arg0, _1> 61{ 62 typedef Arg0 type; 63}; 64 65template<typename Arg0, template<typename...> class T, typename... Pack> 66struct eval<Arg0, T<Pack...> > 67{ 68 typedef T< typename eval<Arg0, Pack>::type... > type; 69}; 70 71static_assert(is_same<eval<int, tuple<float, _1, double>>::type, 72 tuple<float, int, double>>::value, "eval tuple"); 73static_assert(is_same<eval<int, pair<_1, double>>::type, 74 pair<int, double>>::value, "eval pair"); 75static_assert(is_same<eval<int, 76 tuple<pair<_1, _1>, pair<float, float>, 77 pair<double, _1>>>::type, 78 tuple<pair<int, int>, pair<float, float>, pair<double, int>>>::value, 79 "recursive eval"); 80