diff --git a/test/Jamfile b/test/Jamfile index a753bf1..b7e6446 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -7,8 +7,8 @@ exe typeof : main.cpp compliant/test_compliant.cpp - compliant/odr1.cpp - compliant/odr2.cpp + odr1.cpp + odr2.cpp : C:/boost/boost_1_32_0 ../../.. diff --git a/test/compliant/odr.hpp b/test/compliant/odr.hpp deleted file mode 100755 index 040539c..0000000 --- a/test/compliant/odr.hpp +++ /dev/null @@ -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 - -void odr_test1(); -void odr_test2(); - -// trying to cause ODR violation in a class template - -#include - -void odr_test1(); -void odr_test2(); - -#if BOOST_WORKAROUND(BOOST_MSVC,==1200) - -// trying to cause ODR violation in a class template - -template -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 -sum_t::sum_t(const T& t, const U& u) -: m_sum(t + u) -{} - -template -typename sum_t::result_type sum_t::operator()() -{ -// BOOST_AUTO_TPL(result, m_sum); - return m_sum; -} - -template -sum_t make_sum(const T& t, const U& u) -{ - return sum_t(t, u); -} - -// trying to cause ODR violation in a function template - -template -typename sum_t::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 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 -sum_t make_sum(const T& t, const U& u) -{ - return sum_t(t, u); -} - -// trying to cause ODR violation in a function template - -template -typename sum_t::result_type sum(const T& t, const U& u) -{ - BOOST_AUTO_TPL(result, t + u); - return result; -} -#endif - -#endif//ODR_HPP_INCLUDED diff --git a/test/compliant/odr1.cpp b/test/compliant/odr1.cpp deleted file mode 100755 index 14bbd8d..0000000 --- a/test/compliant/odr1.cpp +++ /dev/null @@ -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 - -#include -#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 -} - diff --git a/test/compliant/odr2.cpp b/test/compliant/odr2.cpp deleted file mode 100755 index 783a157..0000000 --- a/test/compliant/odr2.cpp +++ /dev/null @@ -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 -#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 -} diff --git a/test/compliant/test_compliant.cpp b/test/compliant/test_compliant.cpp index ec69a48..3377086 100755 --- a/test/compliant/test_compliant.cpp +++ b/test/compliant/test_compliant.cpp @@ -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 -#if !defined(_MSC_VER) || _MSC_VER > 0x0700 +#include + +// 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 #include "spirit/register.hpp" #include "lambda/register.hpp" #include @@ -92,4 +95,4 @@ namespace negate_test } } -#endif//BOOST_TYPEOF_VINTAGE +#endif//!(BOOST_WORKAROUND(BOOST_MSVC, <= 1300)) diff --git a/test/compliant/typeof.vcproj b/test/compliant/typeof.vcproj index 3b9fb01..6695849 100755 --- a/test/compliant/typeof.vcproj +++ b/test/compliant/typeof.vcproj @@ -220,13 +220,10 @@ RelativePath="..\main.cpp"> + RelativePath="..\odr1.cpp"> - - + RelativePath="..\odr2.cpp"> @@ -239,82 +236,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + ::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); BOOST_STATIC_ASSERT((boost::is_same::value)); - //BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); //BOOST_STATIC_ASSERT((boost::is_same::value)); //BOOST_STATIC_ASSERT((boost::is_same::value)); } diff --git a/test/odr.hpp b/test/odr.hpp index 040539c..ec2969f 100644 --- a/test/odr.hpp +++ b/test/odr.hpp @@ -12,87 +12,85 @@ void odr_test2(); // trying to cause ODR violation in a class template -#include - -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 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 -sum_t::sum_t(const T& t, const U& u) -: m_sum(t + u) -{} - -template -typename sum_t::result_type sum_t::operator()() -{ -// BOOST_AUTO_TPL(result, m_sum); - return m_sum; -} - -template -sum_t make_sum(const T& t, const U& u) -{ - return sum_t(t, u); -} - -// trying to cause ODR violation in a function template - -template -typename sum_t::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 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 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 + sum_t::sum_t(const T& t, const U& u) + : m_sum(t + u) + {} + + template + typename sum_t::result_type sum_t::operator()() + { + // BOOST_AUTO_TPL(result, m_sum); + return m_sum; + } + + template + sum_t make_sum(const T& t, const U& u) + { + return sum_t(t, u); + } + + // trying to cause ODR violation in a function template + + template + typename sum_t::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 -sum_t make_sum(const T& t, const U& u) -{ - return sum_t(t, u); -} +#elif !BOOST_WORKAROUND(BOOST_MSVC,==1300) -// trying to cause ODR violation in a function template + template + 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 + sum_t make_sum(const T& t, const U& u) + { + return sum_t(t, u); + } + + // trying to cause ODR violation in a function template + + template + typename sum_t::result_type sum(const T& t, const U& u) + { + BOOST_AUTO_TPL(result, t + u); + return result; + } -template -typename sum_t::result_type sum(const T& t, const U& u) -{ - BOOST_AUTO_TPL(result, t + u); - return result; -} #endif #endif//ODR_HPP_INCLUDED diff --git a/test/odr1.cpp b/test/odr1.cpp index 14bbd8d..5bc22a0 100644 --- a/test/odr1.cpp +++ b/test/odr1.cpp @@ -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 - #include #include "odr.hpp"