LVALUE_TYPEOF dropped

[SVN r32989]
This commit is contained in:
Arkadiy Vertleyb
2006-02-18 12:56:43 +00:00
parent e359321195
commit 966c338bf0
3 changed files with 0 additions and 140 deletions

View File

@ -1,111 +0,0 @@
// Copyright (C) 2004 Arkadiy Vertleyb
// Copyright (C) 2004 Peder Holt
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_TYPEOF_LVALUE_TYPEOF_HPP_INCLUDED
#define BOOST_TYPEOF_LVALUE_TYPEOF_HPP_INCLUDED
#include <boost/type_traits/is_const.hpp>
namespace boost
{
namespace type_of
{
enum
{
RVALUE = 1,
LVALUE,
CONST_LVALUE
};
char(*classify_expression(...))[
RVALUE
];
template<class T>
char(*classify_expression(T&))[
is_const<T>::value ? CONST_LVALUE : LVALUE
];
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template<class T, int n> struct decorate_type
{
typedef T type;
};
template<class T> struct decorate_type<T, LVALUE>
{
typedef T& type;
};
template<class T> struct decorate_type<T, CONST_LVALUE>
{
typedef const T& type;
};
#else
template<int n>
struct decorate_type_impl {
template<typename T>
struct inner {
typedef T type;
};
};
template<>
struct decorate_type_impl<LVALUE> {
template<typename T>
struct inner {
typedef T& type;
};
};
template<>
struct decorate_type_impl<CONST_LVALUE> {
template<typename T>
struct inner {
typedef T const& type;
};
};
template<class T, int n> struct decorate_type
{
typedef decorate_type_impl<n>::inner<T>::type type;
};
#endif
}
}
// Since this is always a type,
// just add "typename" when using in templates
#ifndef BOOST_TYPEOF_COMPLIANT
#define BOOST_LVALUE_TYPEOF(expr) \
boost::type_of::decorate_type< \
BOOST_TYPEOF(expr), \
sizeof(*boost::type_of::classify_expression(expr)) \
>::type
#else //BOOST_TYPEOF_COMPLIANT
#include <boost/typeof/typeof_impl.hpp>
namespace boost { namespace type_of {
template<class V, int n>
struct decorate_decode_begin
{
typedef typename decorate_type<
typename decode_begin<V>::type,
n
>::type type;
};
}}
#define BOOST_LVALUE_TYPEOF(expr) \
boost::type_of::decorate_decode_begin< \
BOOST_TYPEOF_ENCODED_VECTOR(expr), \
sizeof(*boost::type_of::classify_expression(expr)) \
>::type
#endif
#endif//BOOST_TYPEOF_LVALUE_TYPEOF_HPP_INCLUDED

View File

@ -62,9 +62,6 @@ test-suite "typeof"
[ compile data_member.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : data_member_native ]
[ compile data_member.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : data_member_emulation ]
[ compile lvalue.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : lvalue_native ]
[ compile lvalue.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : lvalue_emulation ]
[ compile noncopyable.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : noncopyable_native ]
[ compile noncopyable.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : noncopyable_emulation ]

View File

@ -1,26 +0,0 @@
#include <boost/typeof/typeof.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
struct x{};
BOOST_TYPEOF_REGISTER_TYPE(x)
x n;
const x cn = n;
x& rn = n;
const x& rcn = cn;
x f();
const x cf();
x& rf();
const x& rcf();
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(n), x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cn), const x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rn), x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rcn), const x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(f()), x>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rf()), x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rcf()), const x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cf()), const x&>::value));