SUPPRESS_UNNAMED_NAMESPACE

[SVN r34347]
This commit is contained in:
Arkadiy Vertleyb
2006-06-18 15:37:56 +00:00
parent 0f458a1ef2
commit ddacb0345b
13 changed files with 157 additions and 81 deletions

View File

@ -8,26 +8,44 @@
#include <boost/mpl/deref.hpp>
#include <boost/mpl/next.hpp>
namespace { namespace boost_typeof {
#ifndef BOOST_TYPEOF_SUPPRESS_UNNAMED_NAMESPACE
template<class V, class Type_Not_Registered_With_Typeof_System>
struct encode_type_impl;
template<class T, class Iter>
struct decode_type_impl
{
typedef int type; // MSVC ETI workaround
};
}}
# define BOOST_TYPEOF_BEGIN_ENCODE_NS namespace { namespace boost_typeof {
# define BOOST_TYPEOF_END_ENCODE_NS }}
# define BOOST_TYPEOF_ENCODE_NS_QUALIFIER boost_typeof
#else
# define BOOST_TYPEOF_BEGIN_ENCODE_NS namespace boost { namespace type_of {
# define BOOST_TYPEOF_END_ENCODE_NS }}
# define BOOST_TYPEOF_ENCODE_NS_QUALIFIER boost::type_of
# define BOOST_TYPEOF_TEXT "unnamed namespace is off"
# include <boost/typeof/message.hpp>
#endif
BOOST_TYPEOF_BEGIN_ENCODE_NS
template<class V, class Type_Not_Registered_With_Typeof_System>
struct encode_type_impl;
template<class T, class Iter>
struct decode_type_impl
{
typedef int type; // MSVC ETI workaround
};
BOOST_TYPEOF_END_ENCODE_NS
namespace boost { namespace type_of {
template<class V, class T>
struct encode_type : boost_typeof::encode_type_impl<V, T>
struct encode_type : BOOST_TYPEOF_ENCODE_NS_QUALIFIER::encode_type_impl<V, T>
{};
template<class Iter>
struct decode_type : boost_typeof::decode_type_impl<
struct decode_type : BOOST_TYPEOF_ENCODE_NS_QUALIFIER::decode_type_impl<
typename Iter::type,
typename Iter::next
>

View File

@ -36,15 +36,15 @@
#define BOOST_TYPEOF_pointer_fun(T) T*
#define BOOST_TYPEOF_reference_fun(T) T&
namespace { namespace boost_typeof {
BOOST_TYPEOF_BEGIN_ENCODE_NS
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_const_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_volatile_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_volatile_const_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_pointer_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_reference_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_const_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_volatile_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_volatile_const_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_pointer_fun);
BOOST_TYPEOF_modifier_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_TYPEOF_reference_fun);
}}
BOOST_TYPEOF_END_ENCODE_NS
#undef BOOST_TYPEOF_modifier_support
#undef BOOST_TYPEOF_const_fun
@ -78,14 +78,14 @@ namespace { namespace boost_typeof {
typedef typename d::iter iter;\
}
namespace { namespace boost_typeof {
BOOST_TYPEOF_BEGIN_ENCODE_NS
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_EMPTY);
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(const));
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(volatile));
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(volatile const));
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_EMPTY);
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(const));
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(volatile));
BOOST_TYPEOF_array_support(BOOST_TYPEOF_UNIQUE_ID(), BOOST_PP_IDENTITY(volatile const));
}}
BOOST_TYPEOF_END_ENCODE_NS
#undef BOOST_TYPEOF_array_support

View File

@ -10,29 +10,30 @@
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
namespace { namespace boost_typeof {
BOOST_TYPEOF_BEGIN_ENCODE_NS
enum {PTR_DATA_MEM_ID = BOOST_TYPEOF_UNIQUE_ID()};
enum {PTR_DATA_MEM_ID = BOOST_TYPEOF_UNIQUE_ID()};
template<class V, class P0, class P1>
struct encode_type_impl<V, P0 P1::*>
{
typedef BOOST_TYPEOF_ENCODE_PARAMS(2, PTR_DATA_MEM_ID) type;
template<class V, class P0, class P1>
struct encode_type_impl<V, P0 P1::*>
{
typedef BOOST_TYPEOF_ENCODE_PARAMS(2, PTR_DATA_MEM_ID) type;
};
template<class Iter>
struct decode_type_impl<boost::mpl::size_t<PTR_DATA_MEM_ID>, Iter>
{
typedef Iter iter0;
BOOST_TYPEOF_DECODE_PARAMS(2)
template<class T> struct workaround{
typedef p0 T::* type;
};
template<class Iter>
struct decode_type_impl<boost::mpl::size_t<PTR_DATA_MEM_ID>, Iter>
{
typedef Iter iter0;
BOOST_TYPEOF_DECODE_PARAMS(2)
typedef typename workaround<p1>::type type;
typedef iter2 iter;
};
template<class T> struct workaround{
typedef p0 T::* type;
};
typedef typename workaround<p1>::type type;
typedef iter2 iter;
};
}}
BOOST_TYPEOF_END_ENCODE_NS
#endif//BOOST_TYPEOF_POINTERS_DATA_MEMBERS_HPP_INCLUDED

View File

@ -32,11 +32,12 @@ enum
VOLATILE_CONST_MEM_FUN_ID = FUN_ID + 6 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY)
};
namespace { namespace boost_typeof {
BOOST_TYPEOF_BEGIN_ENCODE_NS
# define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPEOF_LIMIT_FUNCTION_ARITY)
# define BOOST_PP_FILENAME_1 <boost/typeof/register_functions_iterate.hpp>
# include BOOST_PP_ITERATE()
}}
# define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPEOF_LIMIT_FUNCTION_ARITY)
# define BOOST_PP_FILENAME_1 <boost/typeof/register_functions_iterate.hpp>
# include BOOST_PP_ITERATE()
BOOST_TYPEOF_END_ENCODE_NS
#endif//BOOST_TYPEOF_REGISTER_FUNCTIONS_HPP_INCLUDED

View File

@ -128,7 +128,7 @@
BOOST_TYPEOF_TYPEDEF_DECODED_TEMPLATE_TYPE)(Name,Params)
#define BOOST_TYPEOF_REGISTER_TEMPLATE_IMPL(Name, Params, Size, ID)\
namespace { namespace boost_typeof {\
BOOST_TYPEOF_BEGIN_ENCODE_NS\
BOOST_TYPEOF_REGISTER_TEMPLATE_TEMPLATE_IMPL(Name, Params, ID)\
template<class V\
BOOST_TYPEOF_SEQ_ENUM_TRAILING(Params, BOOST_TYPEOF_REGISTER_TEMPLATE_PARAM_PAIR)\
@ -147,6 +147,6 @@
BOOST_TYPEOF_TYPEDEF_DECODED_TYPE(Name, Params)\
typedef BOOST_PP_CAT(iter, Size) iter;\
};\
}}
BOOST_TYPEOF_END_ENCODE_NS
#endif//BOOST_TYPEOF_TEMPLATE_ENCODING_HPP_INCLUDED

View File

@ -51,21 +51,21 @@
////////////////////////////
// move to encode_decode?
namespace { namespace boost_typeof {
BOOST_TYPEOF_BEGIN_ENCODE_NS
template<class V, class Type_Not_Registered_With_Typeof_System> struct encode_template_impl;
template<class T, class Iter> struct decode_template_impl;
template<class V, class Type_Not_Registered_With_Typeof_System> struct encode_template_impl;
template<class T, class Iter> struct decode_template_impl;
}}
BOOST_TYPEOF_END_ENCODE_NS
namespace boost { namespace type_of {
template<class V, class T> struct encode_template
: boost_typeof::encode_template_impl<V, T>
: BOOST_TYPEOF_ENCODE_NS_QUALIFIER::encode_template_impl<V, T>
{};
template<class Iter> struct decode_template
: boost_typeof::decode_template_impl<typename Iter::type, typename Iter::next>
: BOOST_TYPEOF_ENCODE_NS_QUALIFIER::decode_template_impl<typename Iter::type, typename Iter::next>
{};
}}

View File

@ -17,9 +17,9 @@
};
#define BOOST_TYPEOF_REGISTER_TYPE_EXPLICIT_ID(Type, Id) \
namespace { namespace boost_typeof { \
BOOST_TYPEOF_REGISTER_TYPE_IMPL(Type, Id) \
}}
BOOST_TYPEOF_BEGIN_ENCODE_NS \
BOOST_TYPEOF_REGISTER_TYPE_IMPL(Type, Id) \
BOOST_TYPEOF_END_ENCODE_NS
#define BOOST_TYPEOF_REGISTER_TYPE(Type) \
BOOST_TYPEOF_REGISTER_TYPE_EXPLICIT_ID(Type, BOOST_TYPEOF_UNIQUE_ID())

View File

@ -126,6 +126,7 @@
#ifdef BOOST_TYPEOF_EMULATION
# define BOOST_TYPEOF_TEXT "using typeof emulation"
# include <boost/typeof/message.hpp>
# include <boost/typeof/typeof_impl.hpp>
# include <boost/typeof/type_encoding.hpp>
# include <boost/typeof/template_encoding.hpp>
@ -136,13 +137,12 @@
#elif defined(BOOST_TYPEOF_NATIVE)
# define BOOST_TYPEOF_TEXT "using native typeof"
# include <boost/typeof/message.hpp>
# include <boost/typeof/native.hpp>
#else
# error typeof configuration error
#endif
#include <boost/typeof/message.hpp>
// auto
#define BOOST_AUTO(Var, Expr) BOOST_TYPEOF(Expr) Var = Expr
#define BOOST_AUTO_TPL(Var, Expr) BOOST_TYPEOF_TPL(Expr) Var = Expr

View File

@ -24,59 +24,62 @@ local rule special-requirements ( toolset variant : properties * )
test-suite "typeof"
:
[ compile type.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : type_native ]
[ compile type.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : type_emulation ]
[ compile type.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : type_emulation ]
[ compile template_type.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : template_type_native ]
[ compile template_type.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : template_type_emulation ]
[ compile template_type.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : template_type_emulation ]
[ compile template_int.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : template_int_native ]
[ compile template_int.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : template_int_emulation ]
[ compile template_int.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : template_int_emulation ]
[ compile template_tpl.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : template_tpl_native ]
[ compile template_tpl.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : template_tpl_emulation ]
[ compile template_tpl.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : template_tpl_emulation ]
[ compile template_enum.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : template_enum_native ]
[ compile template_enum.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : template_enum_emulation ]
[ compile template_enum.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : template_enum_emulation ]
[ compile template_dependent.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : template_dependent_native ]
[ compile template_dependent.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : template_dependent_emulation ]
[ compile template_dependent.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : template_dependent_emulation ]
[ compile template_multiword.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : template_multiword_native ]
[ compile template_multiword.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : template_multiword_emulation ]
[ compile template_multiword.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : template_multiword_emulation ]
[ compile modifiers.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : modifiers_native ]
[ compile modifiers.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : modifiers_emulation ]
[ compile modifiers.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : modifiers_emulation ]
[ compile function.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : function_native ]
[ compile function.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : function_emulation ]
[ compile function.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : function_emulation ]
[ compile function_binding.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : function_binding_native ]
[ compile function_binding.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : function_binding_emulation ]
[ compile function_binding.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : function_binding_emulation ]
[ compile function_ptr.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : function_ptr_native ]
[ compile function_ptr.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : function_ptr_emulation ]
[ compile function_ptr.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : function_ptr_emulation ]
[ compile function_ref.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : function_ref_native ]
[ compile function_ref.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : function_ref_emulation ]
[ compile function_ref.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : function_ref_emulation ]
[ compile member_function.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : member_function_native ]
[ compile member_function.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : member_function_emulation ]
[ compile member_function.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : member_function_emulation ]
[ 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 data_member.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : data_member_emulation ]
[ compile noncopyable.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : noncopyable_native ]
[ compile noncopyable.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : noncopyable_emulation ]
[ compile noncopyable.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : noncopyable_emulation ]
[ compile std.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : std_native ]
[ compile std.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : std_emulation ]
[ compile std.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : std_emulation ]
[ run odr1.cpp odr2.cpp : : : <define>BOOST_TYPEOF_NATIVE special-requirements : odr_native ]
[ run odr1.cpp odr2.cpp : : : <define>BOOST_TYPEOF_COMPLIANT special-requirements : odr_emulation ]
[ run odr1.cpp odr2.cpp : : : <define>BOOST_TYPEOF_EMULATION special-requirements : odr_emulation ]
[ compile function_ptr_from_tpl.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : function_ptr_from_tpl_native ]
[ compile function_ptr_from_tpl.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : function_ptr_from_tpl_emulation ]
[ compile function_ptr_from_tpl.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : function_ptr_from_tpl_emulation ]
[ compile nested_typedef.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : nested_typedef_native ]
[ compile nested_typedef.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : nested_typedef_emulation ]
[ compile nested_typedef.cpp : <define>BOOST_TYPEOF_EMULATION special-requirements : nested_typedef_emulation ]
[ run odr_no_uns1.cpp odr_no_uns2.cpp : : : <define>BOOST_TYPEOF_EMULATION special-requirements : odr_no_uns ]
;

15
test/odr_no_uns1.cpp Executable file
View File

@ -0,0 +1,15 @@
#include "odr_no_uns1.hpp"
#include "odr_no_uns2.hpp"
void odr_no_uns1()
{
odr_test_1 t1;
odr_test_2 t2;
BOOST_AUTO(v1, t1);
BOOST_AUTO(v2, t2);
}
int main()
{
return 0;
}

14
test/odr_no_uns1.hpp Executable file
View File

@ -0,0 +1,14 @@
#ifndef BOOST_TYPEOF_ODR_NO_UNS1_HPP_INCLUDED
#define BOOST_TYPEOF_ODR_NO_UNS1_HPP_INCLUDED
#define BOOST_TYPEOF_SUPPRESS_UNNAMED_NAMESPACE
#include <boost/typeof/typeof.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
struct odr_test_1
{};
BOOST_TYPEOF_REGISTER_TYPE(odr_test_1)
#endif//BOOST_TYPEOF_ODR_NO_UNS1_HPP_INCLUDED

10
test/odr_no_uns2.cpp Executable file
View File

@ -0,0 +1,10 @@
#include "odr_no_uns2.hpp"
#include "odr_no_uns1.hpp"
void odr_no_uns2()
{
odr_test_1 t1;
odr_test_2 t2;
BOOST_AUTO(v1, t1);
BOOST_AUTO(v2, t2);
}

14
test/odr_no_uns2.hpp Executable file
View File

@ -0,0 +1,14 @@
#ifndef BOOST_TYPEOF_ODR_NO_UNS2_HPP_INCLUDED
#define BOOST_TYPEOF_ODR_NO_UNS2_HPP_INCLUDED
#define BOOST_TYPEOF_SUPPRESS_UNNAMED_NAMESPACE
#include <boost/typeof/typeof.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
struct odr_test_2
{};
BOOST_TYPEOF_REGISTER_TYPE(odr_test_2)
#endif//BOOST_TYPEOF_ODR_NO_UNS2_HPP_INCLUDED