minor pre-review fixes

[SVN r2578]
This commit is contained in:
Arkadiy Vertleyb
2005-04-17 12:05:32 +00:00
parent 1c297b67de
commit 4e75058453
9 changed files with 128 additions and 283 deletions

View File

@@ -7,8 +7,8 @@ exe typeof
:
main.cpp
compliant/test_compliant.cpp
compliant/odr1.cpp
compliant/odr2.cpp
odr1.cpp
odr2.cpp
:
<include>C:/boost/boost_1_32_0
<include>../../..

View File

@@ -1,98 +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 ODR_HPP_INCLUDED
#define ODR_HPP_INCLUDED
#include <boost/typeof/typeof.hpp>
void odr_test1();
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
{
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)
{
BOOST_AUTO_TPL(result, t + u);
return result;
}
#endif
#endif//ODR_HPP_INCLUDED

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)
#include <boost/typeof/config.hpp>
#include <iostream>
#include "odr.hpp"
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
}

View File

@@ -1,20 +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)
#include <iostream>
#include "odr.hpp"
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
}

View File

@@ -2,14 +2,17 @@
// 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 <boost/typeof/typeof.hpp>
// this test would not work for MSVC 7.0 and earlier,
// since Spirit/Lambda are not supported
#if !(BOOST_WORKAROUND(BOOST_MSVC, <= 1300))
#ifdef _MSC_VER
# pragma warning(disable:4512)
#endif
#include <boost/typeof/typeof.hpp>
#include "spirit/register.hpp"
#include "lambda/register.hpp"
#include <libs/typeof/test/stl/register.hpp>
@@ -92,4 +95,4 @@ namespace negate_test
}
}
#endif//BOOST_TYPEOF_VINTAGE
#endif//!(BOOST_WORKAROUND(BOOST_MSVC, <= 1300))

View File

@@ -220,13 +220,10 @@
RelativePath="..\main.cpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\message.hpp">
RelativePath="..\odr1.cpp">
</File>
<File
RelativePath=".\odr1.cpp">
</File>
<File
RelativePath=".\odr2.cpp">
RelativePath="..\odr2.cpp">
</File>
<File
RelativePath=".\test_compliant.cpp">
@@ -239,82 +236,72 @@
<File
RelativePath="..\..\..\..\boost\typeof\config.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\encode_decode.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\encode_decode_params.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\increment_registration_group.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\int_encoding.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\integral_template_param.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\limit_size.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\lvalue_typeof.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\message.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\modifiers.hpp">
</File>
<File
RelativePath="..\odr.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\pointers_data_members.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\register_functions.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\register_functions_iterate.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\register_fundamental.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\register_mem_functions.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\template_encoding.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\template_template_param.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\type_encoding.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\type_template_param.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\typeof.hpp">
</File>
<Filter
Name="compliant"
Filter="">
<File
RelativePath="..\..\..\..\boost\typeof\compliant\concatenate.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\encode_decode.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\encode_decode_params.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\int_encoding.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\integral_template_param.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\limit_size.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\lvalue_typeof.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\modifiers.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\pointers_data_members.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\register_functions_iterate.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\register_mem_functions.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\template_encoding.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\template_template_param.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\type_encoding.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\type_template_param.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\typeof_impl.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\compliant\vector.hpp">
</File>
</Filter>
<File
RelativePath="..\..\..\..\boost\typeof\typeof_impl.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\typeof\vector.hpp">
</File>
</Filter>
<Filter
Name="spirit"

View File

@@ -190,7 +190,7 @@ void lvalue_typeof_test()
int& rn = n;
const int& rcn = cn;
int f();
//const int cf();
const int cf();
int& rf();
const int& rcf();
@@ -201,7 +201,7 @@ void lvalue_typeof_test()
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(f()), int>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rf()), int&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rcf()), const int&>::value));
//BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cf()), const int&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cf()), const int&>::value));
//BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(21), int>::value));
//BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(int(21)), int>::value));
}

View File

@@ -12,87 +12,85 @@ 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
// 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
{
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()()
template<class T, class U>
class sum_t
{
BOOST_AUTO_TPL(result, m_sum);
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;
}
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);
}
#elif !BOOST_WORKAROUND(BOOST_MSVC,==1300)
// trying to cause ODR violation in a function template
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)
{
BOOST_AUTO_TPL(result, t + u);
return result;
}
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;
}
#endif
#endif//ODR_HPP_INCLUDED

View File

@@ -2,8 +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>
#include <iostream>
#include "odr.hpp"