Removed the vintage implementation and moved compliant implementation to the typeof folder.

[SVN r2570]
This commit is contained in:
Peder Holt committed 2005-04-13 20:24:45 +00:00
1 parent a7a8420f9a
commit 6796fcfc92
54 files changed
+272 -1718

No files matched your search

+50
View File
@@ -12,6 +12,55 @@ void odr_test2();
// trying to cause ODR violation in a class template
#include <boost/typeof/typeof.hpp>
void odr_test1();
void odr_test2();
#if BOOST_WORKAROUND(BOOST_MSVC,==1200)
// trying to cause ODR violation in a class template
template<class T, class U>
class sum_t
{
public:
// VC7 fails using template types in typeof expression.
typedef BOOST_TYPEOF_TPL(T() + U()) result_type;
sum_t(const T& t, const U& u);
BOOST_TYPEOF_TPL(T() + U()) operator()();
private:
BOOST_TYPEOF_TPL(T() + U()) m_sum;
};
template<class T, class U>
sum_t<T,U>::sum_t(const T& t, const U& u)
: m_sum(t + u)
{}
template<class T, class U>
typename sum_t<T,U>::result_type sum_t<T,U>::operator()()
{
// BOOST_AUTO_TPL(result, m_sum);
return m_sum;
}
template<class T, class U>
sum_t<T, U> make_sum(const T& t, const U& u)
{
return sum_t<T, U>(t, u);
}
// trying to cause ODR violation in a function template
template<class T, class U>
typename sum_t<T, U>::result_type sum(const T& t, const U& u)
{
BOOST_AUTO_TPL(result, t + u);
return result;
}
#elif !BOOST_WORKAROUND(BOOST_MSVC,==1300)
template<class T, class U>
class sum_t
{
@@ -44,5 +93,6 @@ typename sum_t<T, U>::result_type sum(const T& t, const U& u)
BOOST_AUTO_TPL(result, t + u);
return result;
}
#endif
#endif//ODR_HPP_INCLUDED
+2 -2
View File
@@ -3,7 +3,6 @@
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#include <boost/typeof/config.hpp>
#if !defined(_MSC_VER) || _MSC_VER > 0x0700
#include <iostream>
#include "odr.hpp"
@@ -12,12 +11,13 @@ using namespace std;
void odr_test1()
{
#if! BOOST_WORKAROUND(BOOST_MSVC,==1300)
char i = 5;
double d = 3.14;
cout << sum(d, i) << endl;
cout << sum(i, d) << endl;
cout << make_sum(d, i)() << endl;
cout << make_sum(i, d)() << endl;
#endif
}
#endif//BOOST_TYPEOF_VINTAGE
+2 -5
View File
@@ -2,9 +2,6 @@
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#include <boost/typeof/config.hpp>
#if !defined(_MSC_VER) || _MSC_VER > 0x0700
#include <iostream>
#include "odr.hpp"
@@ -12,12 +9,12 @@ using namespace std;
void odr_test2()
{
#if! BOOST_WORKAROUND(BOOST_MSVC,==1300)
char i = 5;
double d = 3.14;
cout << sum(d, i) << endl;
cout << sum(i, d) << endl;
cout << make_sum(d, i)() << endl;
cout << make_sum(i, d)() << endl;
#endif
}
#endif //BOOST_TYPEOF_VINTAGE
-4
View File
@@ -325,14 +325,10 @@ namespace test_integral
void odr_test()
{
#if !defined(_MSC_VER) || _MSC_VER > 0x0700
void odr_test1();
void odr_test2();
odr_test1();
odr_test2();
#endif//BOOST_TYPEOF_VINTAGE
}
#define BOOST_TYPEOF_TEXT "main()..."
+41 -1
View File
@@ -10,7 +10,14 @@
void odr_test1();
void odr_test2();
#if! BOOST_WORKAROUND(BOOST_MSVC,==1300)
// trying to cause ODR violation in a class template
#include <boost/typeof/typeof.hpp>
void odr_test1();
void odr_test2();
#if BOOST_WORKAROUND(BOOST_MSVC,==1200)
// trying to cause ODR violation in a class template
@@ -47,6 +54,39 @@ sum_t<T, U> make_sum(const T& t, const U& u)
// trying to cause ODR violation in a function template
template<class T, class U>
typename sum_t<T, U>::result_type sum(const T& t, const U& u)
{
BOOST_AUTO_TPL(result, t + u);
return result;
}
#elif !BOOST_WORKAROUND(BOOST_MSVC,==1300)
template<class T, class U>
class sum_t
{
public:
typedef BOOST_TYPEOF_TPL(T() + U()) result_type;
sum_t(const T& t, const U& u)
: m_sum(t + u)
{}
BOOST_TYPEOF_TPL(T() + U()) operator()()
{
BOOST_AUTO_TPL(result, m_sum);
return result;
}
private:
BOOST_TYPEOF_TPL(T() + U()) m_sum;
};
template<class T, class U>
sum_t<T, U> make_sum(const T& t, const U& u)
{
return sum_t<T, U>(t, u);
}
// trying to cause ODR violation in a function template
template<class T, class U>
typename sum_t<T, U>::result_type sum(const T& t, const U& u)
{
+3
View File
@@ -2,6 +2,8 @@
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#include <boost/typeof/config.hpp>
#include <iostream>
#include "odr.hpp"
@@ -18,3 +20,4 @@ void odr_test1()
cout << make_sum(i, d)() << endl;
#endif
}
File renamed without changes.
-19
View File
@@ -1,19 +0,0 @@
// Copyright (C) 2004 Arkadiy Vertleyb
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#ifndef MPL_REGISTER_HPP_INCLUDED
#define MPL_REGISTER_HPP_INCLUDED
#include <boost/typeof/typeof.hpp>
#include <boost/mpl/vector.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TYPE(boost::mpl::vector0<>);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::mpl::vector1, 1);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::mpl::vector2, 2);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::mpl::vector3, 3);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::mpl::vector4, 4);
#endif//MPL_REGISTER_HPP_INCLUDED
-23
View File
@@ -1,23 +0,0 @@
// Copyright (C) 2004 Arkadiy Vertleyb
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#ifndef STL_REGISTER_HPP_INCLUDED
#define STL_REGISTER_HPP_INCLUDED
#include <boost/typeof/typeof.hpp>
#include <vector>
#include <set>
#include <list>
#include <map>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TEMPLATE_X(std::vector, (class)(class));
BOOST_TYPEOF_REGISTER_TEMPLATE(std::list, 2);
BOOST_TYPEOF_REGISTER_TEMPLATE(std::set, 3);
BOOST_TYPEOF_REGISTER_TEMPLATE(std::allocator, 1);
BOOST_TYPEOF_REGISTER_TEMPLATE(std::less, 1);
#endif//STL_REGISTER_HPP_INCLUDED
-60
View File
@@ -1,60 +0,0 @@
// Copyright (C) 2004 Arkadiy Vertleyb
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#ifndef TYPEID_HPP_INCLUDED
#define TYPEID_HPP_INCLUDED
#include <string>
template<bool IsReference,bool IsConst>
struct typeid_base {
template<typename T>
struct inner {
static std::string name()
{
return typeid(T).name();
}
};
};
template<>
struct typeid_base<true,false> {
template<typename T>
struct inner {
static std::string name()
{
return std::string(typeid(T).name())+"&";
}
};
};
template<>
struct typeid_base<false,true> {
template<typename T>
struct inner {
static std::string name()
{
return std::string(typeid(T).name())+" const";
}
};
};
template<>
struct typeid_base<true,true> {
template<typename T>
struct inner {
static std::string name()
{
return std::string(typeid(T).name())+" const&";
}
};
};
template<class T> struct type_id
: typeid_base<boost::is_reference<T>::value,boost::is_const<T>::value>::inner<T>
{
};
#endif//TYPEID_HPP_INCLUDED