mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 14:54:30 +02:00
Add test for default-identity version
[SVN r16918]
This commit is contained in:
@@ -30,9 +30,9 @@
|
|||||||
namespace mpl = boost::mpl;
|
namespace mpl = boost::mpl;
|
||||||
using mpl::_;
|
using mpl::_;
|
||||||
|
|
||||||
struct printer
|
struct type_printer
|
||||||
{
|
{
|
||||||
printer(std::ostream& s) : f_stream(&s) {}
|
type_printer(std::ostream& s) : f_stream(&s) {}
|
||||||
template< typename U > void operator()(mpl::identity<U>)
|
template< typename U > void operator()(mpl::identity<U>)
|
||||||
{
|
{
|
||||||
*f_stream << typeid(U).name() << '\n';
|
*f_stream << typeid(U).name() << '\n';
|
||||||
@@ -42,6 +42,18 @@ struct printer
|
|||||||
std::ostream* f_stream;
|
std::ostream* f_stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct value_printer
|
||||||
|
{
|
||||||
|
value_printer(std::ostream& s) : f_stream(&s) {}
|
||||||
|
template< typename U > void operator()(U x)
|
||||||
|
{
|
||||||
|
*f_stream << x << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::ostream* f_stream;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __ICL
|
#ifdef __ICL
|
||||||
# pragma warning(disable:985)
|
# pragma warning(disable:985)
|
||||||
#endif
|
#endif
|
||||||
@@ -49,7 +61,7 @@ struct printer
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
typedef mpl::list<char,short,int,long,float,double> types;
|
typedef mpl::list<char,short,int,long,float,double> types;
|
||||||
mpl::for_each< types,mpl::make_identity<_> >(printer(std::cout));
|
mpl::for_each< types,mpl::make_identity<_> >(type_printer(std::cout));
|
||||||
|
|
||||||
typedef mpl::range_c<int,0,10> numbers;
|
typedef mpl::range_c<int,0,10> numbers;
|
||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
@@ -65,6 +77,8 @@ int main()
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mpl::for_each< numbers >(value_printer(std::cout));
|
||||||
|
|
||||||
for (int i = 0; i < v.size(); ++i)
|
for (int i = 0; i < v.size(); ++i)
|
||||||
assert(v[i] == i);
|
assert(v[i] == i);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user