mirror of
https://github.com/boostorg/typeof.git
synced 2025-07-29 20:37:28 +02:00
Merge from trunk
[SVN r39987]
This commit is contained in:
26
test/experimental_1.cpp
Executable file
26
test/experimental_1.cpp
Executable file
@ -0,0 +1,26 @@
|
||||
|
||||
template<typename ID>
|
||||
struct msvc_extract_type
|
||||
{
|
||||
template<bool>
|
||||
struct id2type_impl;
|
||||
|
||||
typedef id2type_impl<true> id2type;
|
||||
};
|
||||
|
||||
template<typename T, typename ID>
|
||||
struct msvc_register_type : msvc_extract_type<ID>
|
||||
{
|
||||
template<>
|
||||
struct id2type_impl<true> //VC7.0 specific bugfeature
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
};
|
||||
|
||||
int main() {
|
||||
sizeof(msvc_register_type<double,int>);
|
||||
typedef msvc_extract_type<int>::id2type::type deduced_type;
|
||||
deduced_type f=5.0;
|
||||
return 0;
|
||||
}
|
39
test/experimental_2.cpp
Executable file
39
test/experimental_2.cpp
Executable file
@ -0,0 +1,39 @@
|
||||
|
||||
struct msvc_extract_type_default_param {};
|
||||
|
||||
template<typename ID, typename T = msvc_extract_type_default_param>
|
||||
struct msvc_extract_type;
|
||||
|
||||
template<typename ID>
|
||||
struct msvc_extract_type<ID, msvc_extract_type_default_param> {
|
||||
template<bool>
|
||||
struct id2type_impl;
|
||||
|
||||
typedef id2type_impl<true> id2type;
|
||||
};
|
||||
|
||||
template<typename ID, typename T>
|
||||
struct msvc_extract_type : msvc_extract_type<ID,msvc_extract_type_default_param>
|
||||
{
|
||||
template<>
|
||||
struct id2type_impl<true> //VC8.0 specific bugfeature
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template<bool>
|
||||
struct id2type_impl;
|
||||
|
||||
typedef id2type_impl<true> id2type;
|
||||
};
|
||||
|
||||
template<typename T, typename ID>
|
||||
struct msvc_register_type : msvc_extract_type<ID, T>
|
||||
{
|
||||
};
|
||||
|
||||
int main() {
|
||||
sizeof(msvc_register_type<double,int>);
|
||||
typedef msvc_extract_type<int>::id2type::type deduced_type;
|
||||
deduced_type f=5.0;
|
||||
return 0;
|
||||
}
|
23
test/experimental_3.cpp
Executable file
23
test/experimental_3.cpp
Executable file
@ -0,0 +1,23 @@
|
||||
|
||||
template<typename ID>
|
||||
struct msvc_extract_type
|
||||
{
|
||||
struct id2type;
|
||||
};
|
||||
|
||||
template<typename T, typename ID>
|
||||
struct msvc_register_type : msvc_extract_type<ID>
|
||||
{
|
||||
typedef msvc_extract_type<ID> base_type;
|
||||
struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
};
|
||||
|
||||
int main() {
|
||||
sizeof(msvc_register_type<double,int>);
|
||||
typedef msvc_extract_type<int>::id2type::type deduced_type;
|
||||
deduced_type f=5.0;
|
||||
return 0;
|
||||
}
|
9
test/experimental_4.cpp
Executable file
9
test/experimental_4.cpp
Executable file
@ -0,0 +1,9 @@
|
||||
#include <typeinfo>
|
||||
|
||||
template<const std::type_info& info>
|
||||
struct msvc_register_type {
|
||||
};
|
||||
|
||||
int main() {
|
||||
msvc_register_type<typeid(double)>;
|
||||
}
|
Reference in New Issue
Block a user