Browse Source
Gerbview: remove flicker when refresh screen. Pcbnew fix (partially) issue when printing in mirror mode ( version compiled with USE_WX_ZOOM = ON specific). Minor enhancements.
pull/1/head
Gerbview: remove flicker when refresh screen. Pcbnew fix (partially) issue when printing in mirror mode ( version compiled with USE_WX_ZOOM = ON specific). Minor enhancements.
pull/1/head
36 changed files with 1294 additions and 522 deletions
-
8common/basicframe.cpp
-
13common/common_plot_functions.cpp
-
12common/drawpanel.cpp
-
2common/zoom.cpp
-
2cvpcb/CMakeLists.txt
-
31cvpcb/menubar.cpp
-
3eeschema/libeditframe.cpp
-
88eeschema/menubar.cpp
-
111eeschema/menubar_libedit.cpp
-
6eeschema/sch_items.cpp
-
1gerbview/CMakeLists.txt
-
61gerbview/class_DCodeSelectionbox.cpp
-
34gerbview/class_DCodeSelectionbox.h
-
2gerbview/draw_gerber_screen.cpp
-
17gerbview/edit.cpp
-
24gerbview/files.cpp
-
267gerbview/gerberframe.cpp
-
1gerbview/gerbview.cpp
-
26gerbview/menubar.cpp
-
55gerbview/toolbars_gerber.cpp
-
222gerbview/wxGerberFrame.h
-
25include/boost/config/platform/vms.hpp
-
26include/boost/type_traits/add_lvalue_reference.hpp
-
67include/boost/type_traits/add_rvalue_reference.hpp
-
153include/boost/type_traits/common_type.hpp
-
25include/boost/type_traits/conditional.hpp
-
302include/boost/type_traits/detail/common_type_imp.hpp
-
29include/boost/typeof/unsupported.hpp
-
44include/boost/utility/declval.hpp
-
3include/class_drawpanel.h
-
2kicad/kicad.cpp
-
84kicad/menubar.cpp
-
8kicad/preferences.cpp
-
21pcbnew/menubar_modedit.cpp
-
27pcbnew/menubar_pcbframe.cpp
-
14pcbnew/printout_controler.cpp
@ -0,0 +1,61 @@ |
|||
/*****************************************************************/ |
|||
/* class_DCodeSelectionbox.cpp: class for displaying DCodes list */ |
|||
/*****************************************************************/ |
|||
|
|||
#include "fctsys.h"
|
|||
#include "appl_wxstruct.h"
|
|||
#include "wxstruct.h"
|
|||
#include "common.h"
|
|||
#include "class_drawpanel.h"
|
|||
#include "gerbview.h"
|
|||
|
|||
#include "class_DCodeSelectionbox.h"
|
|||
|
|||
/*******************************************/ |
|||
/* Helper class for displaying DCodes list */ |
|||
/*******************************************/ |
|||
|
|||
DCODE_SELECTION_BOX::DCODE_SELECTION_BOX( WinEDA_Toolbar* aParent, wxWindowID aId, |
|||
const wxPoint& aLocation, const wxSize& aSize, |
|||
const wxArrayString& aChoices ) : |
|||
wxComboBox( aParent, aId, wxEmptyString, aLocation, aSize, aChoices, wxCB_READONLY ) |
|||
{ |
|||
m_dcodeList = &aChoices; |
|||
} |
|||
|
|||
|
|||
DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX() |
|||
{ |
|||
} |
|||
|
|||
|
|||
int DCODE_SELECTION_BOX::GetSelectedDCodeId() |
|||
{ |
|||
int ii = GetSelection(); |
|||
|
|||
if( ii > 0 ) |
|||
{ |
|||
wxString msg = (*m_dcodeList)[ii].AfterFirst( wxChar( ' ' ) ); |
|||
long id; |
|||
msg.ToLong(&id); |
|||
return id; |
|||
} |
|||
|
|||
return -1; |
|||
} |
|||
|
|||
|
|||
/* SetDCodeSelection
|
|||
* aDCodeId = the DCode Id to select or -1 to select "no dcode" |
|||
*/ |
|||
void DCODE_SELECTION_BOX::SetDCodeSelection( int aDCodeId ) |
|||
{ |
|||
if( aDCodeId > LAST_DCODE ) |
|||
aDCodeId = LAST_DCODE; |
|||
|
|||
int index = 0; |
|||
if( aDCodeId >= FIRST_DCODE ) |
|||
index = aDCodeId - FIRST_DCODE + 1; |
|||
|
|||
SetSelection(index); |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
// file class_DCodeSelectionbox.h |
|||
|
|||
#ifndef CLASS_DCODESELECTIONBOX_H |
|||
#define CLASS_DCODESELECTIONBOX_H |
|||
|
|||
/* helper class to display a DCode list and select a DCode id. |
|||
*/ |
|||
|
|||
// Define event type for DCODE_SELECTION_BOX |
|||
#define EVT_SELECT_DCODE EVT_COMBOBOX |
|||
|
|||
class DCODE_SELECTION_BOX : public wxComboBox |
|||
{ |
|||
private: |
|||
const wxArrayString* m_dcodeList; |
|||
|
|||
public: DCODE_SELECTION_BOX( WinEDA_Toolbar* aParent, wxWindowID aId, |
|||
const wxPoint& aLocation, const wxSize& aSize, |
|||
const wxArrayString& aChoices); |
|||
~DCODE_SELECTION_BOX(); |
|||
|
|||
/** |
|||
* Function GetSelectedDCodeId |
|||
* @return the current selected DCode Id or -1 if no dcode |
|||
*/ |
|||
int GetSelectedDCodeId(); |
|||
/** |
|||
* Function SetDCodeSelection |
|||
* @param aDCodeId = the DCode Id to select or -1 to select "no dcode" |
|||
*/ |
|||
void SetDCodeSelection( int aDCodeId ); |
|||
}; |
|||
|
|||
#endif //CLASS_DCODESELECTIONBOX_H |
|||
@ -0,0 +1,25 @@ |
|||
// (C) Copyright Artyom Beilis 2010.
|
|||
// Use, modification and distribution are subject to the
|
|||
// Boost Software License, Version 1.0. (See accompanying file
|
|||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|||
|
|||
#ifndef BOOST_CONFIG_PLATFORM_VMS_HPP
|
|||
#define BOOST_CONFIG_PLATFORM_VMS_HPP
|
|||
|
|||
#define BOOST_PLATFORM "OpenVMS"
|
|||
|
|||
#undef BOOST_HAS_STDINT_H
|
|||
#define BOOST_HAS_UNISTD_H
|
|||
#define BOOST_HAS_NL_TYPES_H
|
|||
#define BOOST_HAS_GETTIMEOFDAY
|
|||
#define BOOST_HAS_DIRENT_H
|
|||
#define BOOST_HAS_PTHREADS
|
|||
#define BOOST_HAS_NANOSLEEP
|
|||
#define BOOST_HAS_CLOCK_GETTIME
|
|||
#define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE
|
|||
#define BOOST_HAS_LOG1P
|
|||
#define BOOST_HAS_EXPM1
|
|||
#define BOOST_HAS_THREADS
|
|||
#undef BOOST_HAS_SCHED_YIELD
|
|||
|
|||
#endif
|
|||
@ -0,0 +1,26 @@ |
|||
// Copyright 2010 John Maddock
|
|||
|
|||
// Distributed under the Boost Software License, Version 1.0.
|
|||
// See http://www.boost.org/LICENSE_1_0.txt
|
|||
|
|||
#ifndef BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP
|
|||
#define BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP
|
|||
|
|||
#include <boost/type_traits/add_reference.hpp>
|
|||
|
|||
// should be the last #include
|
|||
#include <boost/type_traits/detail/type_trait_def.hpp>
|
|||
|
|||
namespace boost{ |
|||
|
|||
BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_lvalue_reference,T,typename boost::add_reference<T>::type) |
|||
|
|||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
|||
BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,add_lvalue_reference,T&&,T&) |
|||
#endif
|
|||
|
|||
} |
|||
|
|||
#include <boost/type_traits/detail/type_trait_undef.hpp>
|
|||
|
|||
#endif // BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP
|
|||
@ -0,0 +1,67 @@ |
|||
// add_rvalue_reference.hpp ---------------------------------------------------------//
|
|||
|
|||
// Copyright 2010 Vicente J. Botet Escriba
|
|||
|
|||
// Distributed under the Boost Software License, Version 1.0.
|
|||
// See http://www.boost.org/LICENSE_1_0.txt
|
|||
|
|||
#ifndef BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
|
|||
#define BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
|
|||
|
|||
#include <boost/config.hpp>
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
|
|||
#include <boost/type_traits/is_void.hpp>
|
|||
#include <boost/type_traits/is_reference.hpp>
|
|||
|
|||
// should be the last #include
|
|||
#include <boost/type_traits/detail/type_trait_def.hpp>
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
// //
|
|||
// C++03 implementation of //
|
|||
// 20.7.6.2 Reference modifications [meta.trans.ref] //
|
|||
// Written by Vicente J. Botet Escriba //
|
|||
// //
|
|||
// If T names an object or function type then the member typedef type
|
|||
// shall name T&&; otherwise, type shall name T. [ Note: This rule reflects
|
|||
// the semantics of reference collapsing. For example, when a type T names
|
|||
// a type T1&, the type add_rvalue_reference<T>::type is not an rvalue
|
|||
// reference. —end note ]
|
|||
//----------------------------------------------------------------------------//
|
|||
|
|||
namespace boost { |
|||
|
|||
namespace type_traits_detail { |
|||
|
|||
template <typename T, bool b> |
|||
struct add_rvalue_reference_helper |
|||
{ typedef T type; }; |
|||
|
|||
template <typename T> |
|||
struct add_rvalue_reference_helper<T, true> |
|||
{ |
|||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
|||
typedef T&& type; |
|||
#else
|
|||
typedef T type; |
|||
#endif
|
|||
}; |
|||
|
|||
template <typename T> |
|||
struct add_rvalue_reference_imp |
|||
{ |
|||
typedef typename boost::type_traits_detail::add_rvalue_reference_helper |
|||
<T, (!is_void<T>::value && !is_reference<T>::value) >::type type; |
|||
}; |
|||
|
|||
} |
|||
|
|||
BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_rvalue_reference,T,typename boost::type_traits_detail::add_rvalue_reference_imp<T>::type) |
|||
|
|||
} // namespace boost
|
|||
|
|||
#include <boost/type_traits/detail/type_trait_undef.hpp>
|
|||
|
|||
#endif // BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
|
|||
@ -0,0 +1,153 @@ |
|||
// common_type.hpp ---------------------------------------------------------//
|
|||
|
|||
// Copyright 2008 Howard Hinnant
|
|||
// Copyright 2008 Beman Dawes
|
|||
|
|||
// Distributed under the Boost Software License, Version 1.0.
|
|||
// See http://www.boost.org/LICENSE_1_0.txt
|
|||
|
|||
#ifndef BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
|||
#define BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
|||
|
|||
#include <boost/config.hpp>
|
|||
|
|||
#ifdef __SUNPRO_CC
|
|||
# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF
|
|||
#endif
|
|||
#ifdef __IBMCPP__
|
|||
# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF
|
|||
#endif
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
#if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
|||
#define BOOST_COMMON_TYPE_ARITY 3
|
|||
#endif
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
#if defined(BOOST_NO_DECLTYPE) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
|||
#define BOOST_TYPEOF_SILENT
|
|||
#include <boost/typeof/typeof.hpp> // boost wonders never cease!
|
|||
#endif
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
#ifndef BOOST_NO_STATIC_ASSERT
|
|||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG)
|
|||
#elif defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT)
|
|||
#include <boost/mpl/assert.hpp>
|
|||
#include <boost/mpl/bool.hpp>
|
|||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) \
|
|||
BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES) |
|||
#else
|
|||
#include <boost/static_assert.hpp>
|
|||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND)
|
|||
#endif
|
|||
|
|||
#if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT)
|
|||
#define BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE "must be complete type"
|
|||
#endif
|
|||
|
|||
#if defined(BOOST_NO_DECLTYPE) && defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
|||
#include <boost/type_traits/detail/common_type_imp.hpp>
|
|||
#include <boost/type_traits/remove_cv.hpp>
|
|||
#endif
|
|||
#include <boost/mpl/if.hpp>
|
|||
#include <boost/utility/declval.hpp>
|
|||
#include <boost/type_traits/add_rvalue_reference.hpp>
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
// //
|
|||
// C++03 implementation of //
|
|||
// 20.6.7 Other transformations [meta.trans.other] //
|
|||
// Written by Howard Hinnant //
|
|||
// Adapted for Boost by Beman Dawes, Vicente Botet and Jeffrey Hellrung //
|
|||
// //
|
|||
//----------------------------------------------------------------------------//
|
|||
|
|||
namespace boost { |
|||
|
|||
// prototype
|
|||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
|||
template<typename... T> |
|||
struct common_type; |
|||
#else // or no specialization
|
|||
template <class T, class U = void, class V = void> |
|||
struct common_type |
|||
{ |
|||
public: |
|||
typedef typename common_type<typename common_type<T, U>::type, V>::type type; |
|||
}; |
|||
#endif
|
|||
|
|||
|
|||
// 1 arg
|
|||
template<typename T> |
|||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
|||
struct common_type<T> |
|||
#else
|
|||
struct common_type<T, void, void> |
|||
|
|||
#endif
|
|||
{ |
|||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T)); |
|||
public: |
|||
typedef T type; |
|||
}; |
|||
|
|||
// 2 args
|
|||
namespace type_traits_detail { |
|||
|
|||
template <class T, class U> |
|||
struct common_type_2 |
|||
{ |
|||
private: |
|||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T)); |
|||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(U) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (U)); |
|||
static bool declval_bool(); // workaround gcc bug; not required by std
|
|||
static typename add_rvalue_reference<T>::type declval_T(); // workaround gcc bug; not required by std
|
|||
static typename add_rvalue_reference<U>::type declval_U(); // workaround gcc bug; not required by std
|
|||
static typename add_rvalue_reference<bool>::type declval_b(); |
|||
|
|||
#if !defined(BOOST_NO_DECLTYPE)
|
|||
public: |
|||
typedef decltype(declval<bool>() ? declval<T>() : declval<U>()) type; |
|||
#elif defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
|||
public: |
|||
typedef typename detail_type_traits_common_type::common_type_impl< |
|||
typename remove_cv<T>::type, |
|||
typename remove_cv<U>::type |
|||
>::type type; |
|||
#else
|
|||
public: |
|||
typedef BOOST_TYPEOF_TPL(declval_b() ? declval_T() : declval_U()) type; |
|||
#endif
|
|||
}; |
|||
|
|||
template <class T> |
|||
struct common_type_2<T, T> |
|||
{ |
|||
typedef T type; |
|||
}; |
|||
} |
|||
|
|||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
|||
template <class T, class U> |
|||
struct common_type<T, U> |
|||
#else
|
|||
template <class T, class U> |
|||
struct common_type<T, U, void> |
|||
#endif
|
|||
: type_traits_detail::common_type_2<T,U> |
|||
{ }; |
|||
|
|||
|
|||
// 3 or more args
|
|||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
|||
template<typename T, typename U, typename... V> |
|||
struct common_type<T, U, V...> { |
|||
public: |
|||
typedef typename common_type<typename common_type<T, U>::type, V...>::type type; |
|||
}; |
|||
#endif
|
|||
} // namespace boost
|
|||
|
|||
#endif // BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
|||
@ -0,0 +1,25 @@ |
|||
|
|||
// (C) Copyright John Maddock 2010.
|
|||
// Use, modification and distribution are subject to the Boost Software License,
|
|||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|||
// http://www.boost.org/LICENSE_1_0.txt).
|
|||
//
|
|||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
|||
|
|||
|
|||
#ifndef BOOST_TT_CONDITIONAL_HPP_INCLUDED
|
|||
#define BOOST_TT_CONDITIONAL_HPP_INCLUDED
|
|||
|
|||
#include <boost/mpl/if.hpp>
|
|||
|
|||
namespace boost { |
|||
|
|||
template <bool b, class T, class U> |
|||
struct conditional : public mpl::if_c<b, T, U> |
|||
{ |
|||
}; |
|||
|
|||
} // namespace boost
|
|||
|
|||
|
|||
#endif // BOOST_TT_CONDITIONAL_HPP_INCLUDED
|
|||
@ -0,0 +1,302 @@ |
|||
/*******************************************************************************
|
|||
* boost/type_traits/detail/common_type_imp.hpp |
|||
* |
|||
* Copyright 2010, Jeffrey Hellrung. |
|||
* Distributed under the Boost Software License, Version 1.0. (See accompanying |
|||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|||
* |
|||
* struct boost::common_type<T,U> |
|||
* |
|||
* common_type<T,U>::type is the type of the expression |
|||
* b() ? x() : y() |
|||
* where b() returns a bool, x() has return type T, and y() has return type U. |
|||
* See |
|||
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm#common_type
|
|||
* |
|||
* Note that this evaluates to void if one or both of T and U is void. |
|||
******************************************************************************/ |
|||
|
|||
#ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP
|
|||
#define BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP
|
|||
|
|||
#include <cstddef>
|
|||
|
|||
#include <boost/mpl/assert.hpp>
|
|||
#include <boost/mpl/at.hpp>
|
|||
#include <boost/mpl/begin_end.hpp>
|
|||
#include <boost/mpl/contains.hpp>
|
|||
#include <boost/mpl/copy.hpp>
|
|||
#include <boost/mpl/deref.hpp>
|
|||
#include <boost/mpl/eval_if.hpp>
|
|||
#include <boost/mpl/if.hpp>
|
|||
#include <boost/mpl/inserter.hpp>
|
|||
#include <boost/mpl/next.hpp>
|
|||
#include <boost/mpl/or.hpp>
|
|||
#include <boost/mpl/placeholders.hpp>
|
|||
#include <boost/mpl/push_back.hpp>
|
|||
#include <boost/mpl/size.hpp>
|
|||
#include <boost/mpl/vector/vector0.hpp>
|
|||
#include <boost/mpl/vector/vector10.hpp>
|
|||
#include <boost/type_traits/integral_constant.hpp>
|
|||
#include <boost/type_traits/is_enum.hpp>
|
|||
#include <boost/type_traits/is_integral.hpp>
|
|||
#include <boost/type_traits/make_signed.hpp>
|
|||
#include <boost/type_traits/make_unsigned.hpp>
|
|||
#include <boost/type_traits/remove_cv.hpp>
|
|||
#include <boost/type_traits/remove_reference.hpp>
|
|||
#include <boost/utility/declval.hpp>
|
|||
|
|||
namespace boost |
|||
{ |
|||
|
|||
namespace detail_type_traits_common_type |
|||
{ |
|||
|
|||
/*******************************************************************************
|
|||
* struct propagate_cv< From, To > |
|||
* |
|||
* This metafunction propagates cv-qualifiers on type From to type To. |
|||
******************************************************************************/ |
|||
|
|||
template< class From, class To > |
|||
struct propagate_cv |
|||
{ typedef To type; }; |
|||
template< class From, class To > |
|||
struct propagate_cv< const From, To > |
|||
{ typedef To const type; }; |
|||
template< class From, class To > |
|||
struct propagate_cv< volatile From, To > |
|||
{ typedef To volatile type; }; |
|||
template< class From, class To > |
|||
struct propagate_cv< const volatile From, To > |
|||
{ typedef To const volatile type; }; |
|||
|
|||
/*******************************************************************************
|
|||
* struct is_signable_integral<T> |
|||
* |
|||
* This metafunction determines if T is an integral type which can be made |
|||
* signed or unsigned. |
|||
******************************************************************************/ |
|||
|
|||
template< class T > |
|||
struct is_signable_integral |
|||
: mpl::or_< is_integral<T>, is_enum<T> > |
|||
{ }; |
|||
template<> |
|||
struct is_signable_integral< bool > |
|||
: false_type |
|||
{ }; |
|||
|
|||
/*******************************************************************************
|
|||
* struct sizeof_t<N> |
|||
* typedef ... yes_type |
|||
* typedef ... no_type |
|||
* |
|||
* These types are integral players in the use of the "sizeof trick", i.e., we |
|||
* can distinguish overload selection by inspecting the size of the return type |
|||
* of the overload. |
|||
******************************************************************************/ |
|||
|
|||
template< std::size_t N > struct sizeof_t { char _dummy[N]; }; |
|||
typedef sizeof_t<1> yes_type; |
|||
typedef sizeof_t<2> no_type; |
|||
BOOST_MPL_ASSERT_RELATION( sizeof( yes_type ), ==, 1 ); |
|||
BOOST_MPL_ASSERT_RELATION( sizeof( no_type ), ==, 2 ); |
|||
|
|||
/*******************************************************************************
|
|||
* rvalue_test(T&) -> no_type |
|||
* rvalue_test(...) -> yes_type |
|||
* |
|||
* These overloads are used to determine the rvalue-ness of an expression. |
|||
******************************************************************************/ |
|||
|
|||
template< class T > no_type rvalue_test(T&); |
|||
yes_type rvalue_test(...); |
|||
|
|||
/*******************************************************************************
|
|||
* struct conversion_test_overloads< Sequence > |
|||
* |
|||
* This struct has multiple overloads of the static member function apply, each |
|||
* one taking a single parameter of a type within the Boost.MPL sequence |
|||
* Sequence. Each such apply overload has a return type with sizeof equal to |
|||
* one plus the index of the parameter type within Sequence. Thus, we can |
|||
* deduce the type T of an expression as long as we can generate a finite set of |
|||
* candidate types containing T via these apply overloads and the "sizeof |
|||
* trick". |
|||
******************************************************************************/ |
|||
|
|||
template< class First, class Last, std::size_t Index > |
|||
struct conversion_test_overloads_iterate |
|||
: conversion_test_overloads_iterate< |
|||
typename mpl::next< First >::type, Last, Index + 1 |
|||
> |
|||
{ |
|||
using conversion_test_overloads_iterate< |
|||
typename mpl::next< First >::type, Last, Index + 1 |
|||
>::apply; |
|||
static sizeof_t< Index + 1 > |
|||
apply(typename mpl::deref< First >::type); |
|||
}; |
|||
|
|||
template< class Last, std::size_t Index > |
|||
struct conversion_test_overloads_iterate< Last, Last, Index > |
|||
{ static sizeof_t< Index + 1 > apply(...); }; |
|||
|
|||
template< class Sequence > |
|||
struct conversion_test_overloads |
|||
: conversion_test_overloads_iterate< |
|||
typename mpl::begin< Sequence >::type, |
|||
typename mpl::end< Sequence >::type, |
|||
0 |
|||
> |
|||
{ }; |
|||
|
|||
/*******************************************************************************
|
|||
* struct select< Sequence, Index > |
|||
* |
|||
* select is synonymous with mpl::at_c unless Index equals the size of the |
|||
* Boost.MPL Sequence, in which case this evaluates to void. |
|||
******************************************************************************/ |
|||
|
|||
template< |
|||
class Sequence, int Index, |
|||
int N = mpl::size< Sequence >::value |
|||
> |
|||
struct select |
|||
: mpl::at_c< Sequence, Index > |
|||
{ }; |
|||
template< class Sequence, int N > |
|||
struct select< Sequence, N, N > |
|||
{ typedef void type; }; |
|||
|
|||
/*******************************************************************************
|
|||
* class deduce_common_type< T, U, NominalCandidates > |
|||
* struct nominal_candidates<T,U> |
|||
* struct common_type_dispatch_on_rvalueness<T,U> |
|||
* struct common_type_impl<T,U> |
|||
* |
|||
* These classes and structs implement the logic behind common_type, which goes |
|||
* roughly as follows. Let C be the type of the conditional expression |
|||
* declval< bool >() ? declval<T>() : declval<U>() |
|||
* if C is an rvalue, then: |
|||
* let T' and U' be T and U stripped of reference- and cv-qualifiers |
|||
* if T' and U' are pointer types, say, T' = V* and U' = W*, then: |
|||
* define the set of NominalCandidates to be |
|||
* { V*, W*, V'*, W'* } |
|||
* where V' is V with whatever cv-qualifiers are on W, and W' is W |
|||
* with whatever cv-qualifiers are on V |
|||
* else T' and U' are both "signable integral types" (integral and enum |
|||
* types excepting bool), then: |
|||
* define the set of NominalCandidates to be |
|||
* { unsigned(T'), unsigned(U'), signed(T'), signed(U') } |
|||
* where unsigned(X) is make_unsigned<X>::type and signed(X) is |
|||
* make_signed<X>::type |
|||
* else |
|||
* define the set of NominalCandidates to be |
|||
* { T', U' } |
|||
* else |
|||
* let V and W be T and U stripped of reference-qualifiers |
|||
* define the set of NominalCandidates to be |
|||
* { V&, W&, V'&, W'& } |
|||
* where V' is V with whatever cv-qualifiers are on W, and W' is W with |
|||
* whatever cv-qualifiers are on V |
|||
* define the set of Candidates to be equal to the set of NominalCandidates with |
|||
* duplicates removed, and use this set of Candidates to determine C using the |
|||
* conversion_test_overloads struct |
|||
******************************************************************************/ |
|||
|
|||
template< class T, class U, class NominalCandidates > |
|||
class deduce_common_type |
|||
{ |
|||
typedef typename mpl::copy< |
|||
NominalCandidates, |
|||
mpl::inserter< |
|||
mpl::vector0<>, |
|||
mpl::if_< |
|||
mpl::contains< mpl::_1, mpl::_2 >, |
|||
mpl::_1, |
|||
mpl::push_back< mpl::_1, mpl::_2 > |
|||
> |
|||
> |
|||
>::type candidate_types; |
|||
static const int best_candidate_index = |
|||
sizeof( conversion_test_overloads< candidate_types >::apply( |
|||
declval< bool >() ? declval<T>() : declval<U>() |
|||
) ) - 1; |
|||
public: |
|||
typedef typename select< candidate_types, best_candidate_index >::type type; |
|||
}; |
|||
|
|||
template< |
|||
class T, class U, |
|||
class V = typename remove_cv< typename remove_reference<T>::type >::type, |
|||
class W = typename remove_cv< typename remove_reference<U>::type >::type, |
|||
bool = is_signable_integral<V>::value && is_signable_integral<W>::value |
|||
> |
|||
struct nominal_candidates; |
|||
|
|||
template< class T, class U, class V, class W > |
|||
struct nominal_candidates< T, U, V, W, false > |
|||
{ typedef mpl::vector2<V,W> type; }; |
|||
|
|||
template< class T, class U, class V, class W > |
|||
struct nominal_candidates< T, U, V, W, true > |
|||
{ |
|||
typedef mpl::vector4< |
|||
typename make_unsigned<V>::type, |
|||
typename make_unsigned<W>::type, |
|||
typename make_signed<V>::type, |
|||
typename make_signed<W>::type |
|||
> type; |
|||
}; |
|||
|
|||
template< class T, class U, class V, class W > |
|||
struct nominal_candidates< T, U, V*, W*, false > |
|||
{ |
|||
typedef mpl::vector4< |
|||
V*, W*, |
|||
typename propagate_cv<W,V>::type *, |
|||
typename propagate_cv<V,W>::type * |
|||
> type; |
|||
}; |
|||
|
|||
template<class T, class U, bool b> |
|||
struct common_type_dispatch_on_rvalueness |
|||
: deduce_common_type< T, U, typename nominal_candidates<T,U>::type > |
|||
{ }; |
|||
|
|||
template< class T, class U > |
|||
struct common_type_dispatch_on_rvalueness< T, U, false > |
|||
{ |
|||
private: |
|||
typedef typename remove_reference<T>::type unrefed_T_type; |
|||
typedef typename remove_reference<U>::type unrefed_U_type; |
|||
public: |
|||
typedef typename deduce_common_type< |
|||
T, U, |
|||
mpl::vector4< |
|||
unrefed_T_type &, |
|||
unrefed_U_type &, |
|||
typename propagate_cv< unrefed_U_type, unrefed_T_type >::type &, |
|||
typename propagate_cv< unrefed_T_type, unrefed_U_type >::type & |
|||
> |
|||
>::type type; |
|||
}; |
|||
|
|||
template< class T, class U > |
|||
struct common_type_impl |
|||
: common_type_dispatch_on_rvalueness<T,U, sizeof( ::boost::detail_type_traits_common_type::rvalue_test( |
|||
declval< bool >() ? declval<T>() : declval<U>() ) ) == sizeof( yes_type ) > |
|||
{ }; |
|||
|
|||
template< class T > struct common_type_impl< T, void > { typedef void type; }; |
|||
template< class T > struct common_type_impl< void, T > { typedef void type; }; |
|||
template<> struct common_type_impl< void, void > { typedef void type; }; |
|||
|
|||
} // namespace detail_type_traits_common_type
|
|||
|
|||
|
|||
} // namespace boost
|
|||
|
|||
#endif // BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_HPP
|
|||
|
|||
@ -0,0 +1,29 @@ |
|||
// Copyright (C) 2010 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_UNSUPPORTED_HPP_INCLUDED
|
|||
#define BOOST_TYPEOF_UNSUPPORTED_HPP_INCLUDED
|
|||
|
|||
namespace boost { namespace type_of { |
|||
struct typeof_emulation_is_unsupported_on_this_compiler {}; |
|||
}} |
|||
|
|||
#define BOOST_TYPEOF(expr) boost::type_of::typeof_emulation_is_unsupported_on_this_compiler
|
|||
#define BOOST_TYPEOF_TPL BOOST_TYPEOF
|
|||
|
|||
#define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \
|
|||
struct name {\ |
|||
typedef BOOST_TYPEOF_TPL(expr) type;\ |
|||
}; |
|||
|
|||
#define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \
|
|||
struct name {\ |
|||
typedef BOOST_TYPEOF(expr) type;\ |
|||
}; |
|||
|
|||
|
|||
#define BOOST_TYPEOF_REGISTER_TYPE(x)
|
|||
#define BOOST_TYPEOF_REGISTER_TEMPLATE(x, params)
|
|||
|
|||
#endif
|
|||
@ -0,0 +1,44 @@ |
|||
// common_type.hpp ---------------------------------------------------------//
|
|||
|
|||
// Copyright 2010 Vicente J. Botet Escriba
|
|||
|
|||
// Distributed under the Boost Software License, Version 1.0.
|
|||
// See http://www.boost.org/LICENSE_1_0.txt
|
|||
|
|||
#ifndef BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
|
|||
#define BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
|
|||
|
|||
#include <boost/config.hpp>
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
|
|||
#include <boost/type_traits/add_rvalue_reference.hpp>
|
|||
|
|||
//----------------------------------------------------------------------------//
|
|||
// //
|
|||
// C++03 implementation of //
|
|||
// Written by Vicente J. Botet Escriba //
|
|||
//~ 20.3.4 Function template declval [declval]
|
|||
//~ 1 The library provides the function template declval to simplify the definition of expressions which occur as
|
|||
//~ unevaluated operands.
|
|||
//~ 2 Remarks: If this function is used, the program is ill-formed.
|
|||
//~ 3 Remarks: The template parameter T of declval may be an incomplete type.
|
|||
//~ [ Example:
|
|||
|
|||
//~ template <class To, class From>
|
|||
//~ decltype(static_cast<To>(declval<From>())) convert(From&&);
|
|||
|
|||
//~ declares a function template convert which only participats in overloading if the type From can be
|
|||
//~ explicitly converted to type To. For another example see class template common_type (20.7.6.6). —end
|
|||
//~ example ]
|
|||
// //
|
|||
//----------------------------------------------------------------------------//
|
|||
|
|||
namespace boost { |
|||
|
|||
template <typename T> |
|||
typename add_rvalue_reference<T>::type declval(); //noexcept; // as unevaluated operand
|
|||
|
|||
} // namespace boost
|
|||
|
|||
#endif // BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue