/usr/include/boost/interprocess/detail/move.hpp is in libboost1.46-dev 1.46.1-7ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | //////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright David Abrahams, Vicente Botet 2009.
// (C) Copyright Ion Gaztanaga 2009-2010.
// 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)
//
// See http://www.boost.org/libs/move for documentation.
//
//////////////////////////////////////////////////////////////////////////////
//! \file
#ifndef BOOST_MOVE_DETAIL_MOVE_HPP
#define BOOST_MOVE_DETAIL_MOVE_HPP
#include <boost/config.hpp>
#include <algorithm> //copy, copy_backward
#include <memory> //uninitialized_copy
#include <iterator> //std::iterator
#include <boost/mpl/if.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/utility/addressof.hpp>
//! Defining or undefining this macro will change Boost.Move behaviour
//! for copyable and movable classes when assigning from non-const rvalues:
//! \code
//! copyable_and_movable produce(){ return copyable_and_movable(); }
//! \endcode
//! If the macro is NOT defined:
//! \code
//! copyable_and_movable cm;
//! cm = copyable_and_movable(); //object is COPIED (missed optimization)
//! \endcode
//! If the macro IS defined:
//! \code
//! copyable_and_movable cm;
//! cm = copyable_and_movable(); //object is MOVED
//! \endcode
//! However, the second option has also some downsides. See documentation for more details.
#define BOOST_MOVE_OPTIMIZED_EMULATION
/// @cond
//Define to easily port between Boost.Move and internal Boost.Interprocess move emulation
//
// This configuration is temporary. Boost.Interprocess emulation uses
// different macros to avoid any redefinition of a top-levl Boost macro.
// It will disappear once the library is accepted and
// Boost.Interprocess is updated to the standard interface.
//
#define BOOST_MOVE_IN_BOOST_INTERPROCESS_NAMESPACE
#ifdef BOOST_MOVE_IN_BOOST_INTERPROCESS_NAMESPACE
#define INTERPROCESS_NAMESPACE_BEGIN namespace interprocess {
#define INTERPROCESS_NAMESPACE_END }// namespace interprocess {
#define BOOST_MOVE_NAMESPACE boost::interprocess
#else //BOOST_MOVE_IN_BOOST_INTERPROCESS_NAMESPACE
#define INTERPROCESS_NAMESPACE_BEGIN
#define INTERPROCESS_NAMESPACE_END
#define BOOST_MOVE_NAMESPACE boost
#endif //BOOST_MOVE_IN_BOOST_INTERPROCESS_NAMESPACE
namespace boost {
INTERPROCESS_NAMESPACE_BEGIN
namespace move_detail {
template <class T>
struct identity
{
typedef T type;
};
template <class T, class U>
class is_convertible
{
typedef char true_t;
class false_t { char dummy[2]; };
static true_t dispatch(U);
static false_t dispatch(...);
static T trigger();
public:
enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
};
} //namespace move_detail {
INTERPROCESS_NAMESPACE_END
} //namespace boost {
/// @endcond
#if !defined(BOOST_NO_RVALUE_REFERENCES)
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5)
#define BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
#else
#if defined(_MSC_VER) && (_MSC_VER == 1600)
#define BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
#endif
#endif
#endif
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_same.hpp>
#ifdef __GNUC__
# define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__))
#else
# define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS
#endif
namespace boost {
INTERPROCESS_NAMESPACE_BEGIN
//////////////////////////////////////////////////////////////////////////////
//
// struct rv
//
//////////////////////////////////////////////////////////////////////////////
template <class T>
class rv : public T
{
rv();
~rv();
rv(rv const&);
void operator=(rv const&);
} BOOST_MOVE_ATTRIBUTE_MAY_ALIAS;
//////////////////////////////////////////////////////////////////////////////
//
// move_detail::is_rv
//
//////////////////////////////////////////////////////////////////////////////
namespace move_detail {
template <class T>
struct is_rv
{
static const bool value = false;
};
template <class T>
struct is_rv< rv<T> >
{
static const bool value = true;
};
} //namespace move_detail {
//////////////////////////////////////////////////////////////////////////////
//
// is_movable
//
//////////////////////////////////////////////////////////////////////////////
template<class T>
struct is_movable
: public ::boost::mpl::bool_<move_detail::is_convertible<T, rv<T>&>::value>
{
};
template<class T>
struct is_movable< rv<T> >
: public ::boost::mpl::bool_<false>
{
};
template <class T>
struct has_nothrow_move
: public ::boost::mpl::bool_<false>
{
};
//////////////////////////////////////////////////////////////////////////////
//
// move()
//
//////////////////////////////////////////////////////////////////////////////
template <class T>
typename ::boost::disable_if<is_movable<T>, T&>::type move(T& x)
{
return x;
}
template <class T>
typename enable_if<is_movable<T>, rv<T>&>::type move(T& x)
{
return *static_cast<rv<T>* >(boost::addressof(x));
}
template <class T>
typename enable_if<is_movable<T>, rv<T>&>::type move(rv<T>& x)
{
return x;
}
#define BOOST_RV_REF(TYPE)\
::BOOST_MOVE_NAMESPACE::rv< TYPE >& \
//
#define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
::BOOST_MOVE_NAMESPACE::rv< TYPE<ARG1, ARG2> >& \
//
#define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
::BOOST_MOVE_NAMESPACE::rv< TYPE<ARG1, ARG2, ARG3> >& \
//
#define BOOST_FWD_REF(TYPE)\
const TYPE & \
//
#define BOOST_CATCH_CONST_RLVALUE(TYPE)\
const ::BOOST_MOVE_NAMESPACE::rv< TYPE >& \
//
#ifdef BOOST_MOVE_OPTIMIZED_EMULATION
#define BOOST_COPY_ASSIGN_REF(TYPE)\
const ::BOOST_MOVE_NAMESPACE::rv< TYPE >& \
//
#define BOOST_MOVE_MACRO_COPY_ASSIGN_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
const ::BOOST_MOVE_NAMESPACE::rv< TYPE<ARG1, ARG2> >& \
//
#define BOOST_MOVE_MACRO_COPY_ASSIGN_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
const ::BOOST_MOVE_NAMESPACE::rv< TYPE<ARG1, ARG2, ARG3> >& \
//
//////////////////////////////////////////////////////////////////////////////
//
// forward()
//
//////////////////////////////////////////////////////////////////////////////
template <class T>
typename enable_if< ::BOOST_MOVE_NAMESPACE::move_detail::is_rv<T>, T &>::type
forward(const typename move_detail::identity<T>::type &x)
{
return const_cast<T&>(x);
}
template <class T>
typename disable_if< ::BOOST_MOVE_NAMESPACE::move_detail::is_rv<T>, const T &>::type
forward(const typename move_detail::identity<T>::type &x)
{
return x;
}
#else //BOOST_MOVE_OPTIMIZED_EMULATION
#define BOOST_COPY_ASSIGN_REF(TYPE)\
const TYPE & \
//
#define BOOST_MOVE_MACRO_COPY_ASSIGN_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
const TYPE< ARG1, ARG2 >& \
//
#define BOOST_MOVE_MACRO_COPY_ASSIGN_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
const TYPE< ARG1, ARG2, ARG3 > & \
//
//////////////////////////////////////////////////////////////////////////////
//
// forward()
//
//////////////////////////////////////////////////////////////////////////////
//Catches const lvalues for movable types
template <class T>
const T&
forward( BOOST_CATCH_CONST_RLVALUE(T) x
, typename ::boost::enable_if_c< ::BOOST_MOVE_NAMESPACE::is_movable<T>::value >::type* = 0)
{
return static_cast<const T&>(x);
}
//Catches const lvalues for non-movable types
template <class T>
const T&
forward( const T &x
, typename ::boost::enable_if_c< !::BOOST_MOVE_NAMESPACE::is_movable<T>::value &&
!::boost::move_detail::is_rv<T>::value
>::type* = 0)
{
return static_cast<const T&>(x);
}
//Catches forwarded ::boost::rv<T> via BOOST_FWD_REFs
template <class T>
T &
forward( const T &t
, typename ::boost::enable_if_c< ::boost::move_detail::is_rv<T>::value >::type* = 0)
{
return const_cast<T&>(t);
}
//Catches forwarded ::boost::rv<T>
template <class T, class U>
const T &
forward( const U &u
, typename ::boost::enable_if_c< ::boost::is_same< ::boost::rv<T>, U >::value >::type * = 0)
{
return static_cast<const T&>(u);
}
//Catches non-const lvalues
template <class T>
T&
forward( typename move_detail::identity<T>::type &x
, typename ::boost::enable_if_c< !::boost::move_detail::is_rv<T>::value >::type* = 0)
{
return x;
}
//Catches non-const rvalues
template <class T>
typename enable_if<is_movable<T>, ::boost::rv<T> & >::type
forward(BOOST_RV_REF(T) x)
{ return x; }
#endif
//////////////////////////////////////////////////////////////////////////////
//
// BOOST_MOVABLE_BUT_NOT_COPYABLE
//
//////////////////////////////////////////////////////////////////////////////
#define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\
private:\
TYPE(TYPE &);\
TYPE& operator=(TYPE &);\
public:\
operator ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() \
{ return *static_cast< ::BOOST_MOVE_NAMESPACE::rv<TYPE>* >(this); }\
operator const ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() const \
{ return *static_cast<const ::BOOST_MOVE_NAMESPACE::rv<TYPE>* >(this); }\
private:\
//
//////////////////////////////////////////////////////////////////////////////
//
// BOOST_COPYABLE_AND_MOVABLE
//
//////////////////////////////////////////////////////////////////////////////
#ifdef BOOST_MOVE_OPTIMIZED_EMULATION
#define BOOST_COPYABLE_AND_MOVABLE(TYPE)\
public:\
TYPE& operator=(TYPE &t)\
{ this->operator=(static_cast<const ::BOOST_MOVE_NAMESPACE::rv<TYPE> &>(const_cast<const TYPE &>(t))); return *this;}\
public:\
operator ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() \
{ return *static_cast< ::BOOST_MOVE_NAMESPACE::rv<TYPE>* >(this); }\
operator const ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() const \
{ return *static_cast<const ::BOOST_MOVE_NAMESPACE::rv<TYPE>* >(this); }\
private:\
//
#else //#ifdef BOOST_MOVE_OPTIMIZED_EMULATION
#define BOOST_COPYABLE_AND_MOVABLE(TYPE)\
public:\
operator ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() \
{ return *static_cast< ::BOOST_MOVE_NAMESPACE::rv<TYPE>* >(this); }\
operator const ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() const \
{ return *static_cast<const ::BOOST_MOVE_NAMESPACE::rv<TYPE>* >(this); }\
private:\
//
#endif
INTERPROCESS_NAMESPACE_END
} //namespace boost
#else //BOOST_NO_RVALUE_REFERENCES
#include <boost/type_traits/remove_reference.hpp>
namespace boost {
INTERPROCESS_NAMESPACE_BEGIN
/// @cond
namespace move_detail {
template<class T>
struct is_lvalue_reference
: public ::boost::mpl::bool_<false>
{};
template<class T>
struct is_lvalue_reference<T&>
: public ::boost::mpl::bool_<true>
{};
typedef char one;
struct two {one _[2];};
template <class T>
struct internal_member_value_traits
{
template <class U> static one test(...);
template <class U> static two test(typename U::boost_move_emulation_t* = 0);
static const bool value = sizeof(test<T>(0)) == sizeof(two);
};
} //namespace move_detail {
/// @endcond
//////////////////////////////////////////////////////////////////////////////
//
// is_movable
//
//////////////////////////////////////////////////////////////////////////////
//! For compilers with rvalue references, this traits class returns true
//! if BOOST_ENABLE_MOVE_EMULATION is activated.
//!
//! For other compilers returns true if T is convertible to <i>::boost::rv<T>&</i>
template<class T>
struct is_movable
: public ::boost::mpl::bool_<move_detail::internal_member_value_traits<T>::value>
{
};
//! By default this traits returns false. Classes with non-thworing move construction
//! and assignment should specialize this trait to obtain some performance improvements.
template <class T>
struct has_nothrow_move
: public ::boost::mpl::bool_<false>
{};
//////////////////////////////////////////////////////////////////////////////
//
// move
//
//////////////////////////////////////////////////////////////////////////////
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
//! This function provides a way to convert a reference into a rvalue reference
//! in compilers with rvalue references. For other compilers converts T & into
//! <i>::boost::rv<T> &</i> so that move emulation is activated.
template <class T> inline
rvalue_reference move (input_reference);
#else //BOOST_MOVE_DOXYGEN_INVOKED
#if defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
//Old move approach, lvalues could bind to rvalue references
template <class T> inline
typename remove_reference<T>::type && move(T&& t)
{ return t; }
#else //Old move
template <class T> inline
typename remove_reference<T>::type && move(T&& t)
{ return static_cast<typename remove_reference<T>::type &&>(t); }
#endif //Old move
#endif //BOOST_MOVE_DOXYGEN_INVOKED
//////////////////////////////////////////////////////////////////////////////
//
// forward
//
//////////////////////////////////////////////////////////////////////////////
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
//! This function provides limited form of forwarding that is usually enough for
//! in-place construction and avoids the exponential overloading necessary for
//! perfect forwarding in C++03.
//!
//! For compilers with rvalue references this function provides perfect forwarding.
//!
//! Otherwise:
//! * If input_reference binds to const ::boost::rv<T> & then it output_reference is
//! ::boost::rev<T> &
//!
//! * Else, input_reference is equal to output_reference is equal to input_reference.
template <class T> inline output_reference forward(input_reference);
#else
#if defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
//Old move approach, lvalues could bind to rvalue references
template <class T> inline
T&& forward (typename move_detail::identity<T>::type&& t)
{ return t; }
#else //Old move
//Implementation #5 from N2951, thanks to Howard Hinnant
template <class T, class U>
inline T&& forward(U&& t
, typename enable_if_c<
move_detail::is_lvalue_reference<T>::value ? move_detail::is_lvalue_reference<U>::value : true>::type * = 0/*
, typename enable_if_c<
move_detail::is_convertible
<typename remove_reference<U>::type*, typename remove_reference<T>::type*>::value>::type * = 0*/)
{ return static_cast<T&&>(t); }
#endif //Old move
#endif //BOOST_MOVE_DOXYGEN_INVOKED
//////////////////////////////////////////////////////////////////////////////
//
// BOOST_ENABLE_MOVE_EMULATION
//
//////////////////////////////////////////////////////////////////////////////
///@cond
#define BOOST_ENABLE_MOVE_EMULATION(TYPE)\
typedef int boost_move_emulation_t;
\
//
/// @endcond
//! This macro marks a type as movable but not copyable, disabling copy construction
//! and assignment. The user will need to write a move constructor/assignment as explained
//! in the documentation to fully write a movable but not copyable class.
#define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\
public:\
typedef int boost_move_emulation_t;\
private:\
TYPE(const TYPE &);\
TYPE& operator=(const TYPE &);\
//
//! This macro marks a type as copyable and movable.
//! The user will need to write a move constructor/assignment and a copy assignment
//! as explained in the documentation to fully write a copyable and movable class.
#define BOOST_COPYABLE_AND_MOVABLE(TYPE)\
typedef int boost_move_emulation_t;
//
/// @cond
#define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
TYPE<ARG1, ARG2> && \
//
#define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
TYPE<ARG1, ARG2, ARG3> && \
//
/// @endcond
//!This macro is used to achieve portable syntax in move
//!constructors and assignments for classes marked as
//!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE
#define BOOST_RV_REF(TYPE)\
TYPE && \
//
//!This macro is used to achieve portable syntax in copy
//!assignment for classes marked as BOOST_COPYABLE_AND_MOVABLE.
#define BOOST_COPY_ASSIGN_REF(TYPE)\
const TYPE & \
//
/// @cond
#define BOOST_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\
const TYPE<ARG1, ARG2> & \
//
#define BOOST_COPY_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\
TYPE<ARG1, ARG2, ARG3>& \
//
/// @endcond
//! This macro is used to implement portable perfect forwarding
//! as explained in the documentation.
#define BOOST_FWD_REF(TYPE)\
TYPE && \
//
/// @cond
#define BOOST_CATCH_CONST_RLVALUE(TYPE)\
const TYPE & \
//
/// @endcond
INTERPROCESS_NAMESPACE_END
} //namespace boost {
#endif //BOOST_NO_RVALUE_REFERENCES
namespace boost {
INTERPROCESS_NAMESPACE_BEGIN
//////////////////////////////////////////////////////////////////////////////
//
// move_iterator
//
//////////////////////////////////////////////////////////////////////////////
//! Class template move_iterator is an iterator adaptor with the same behavior
//! as the underlying iterator except that its dereference operator implicitly
//! converts the value returned by the underlying iterator's dereference operator
//! to an rvalue reference. Some generic algorithms can be called with move
//! iterators to replace copying with moving.
template <class It>
class move_iterator
{
public:
typedef It iterator_type;
typedef typename std::iterator_traits<iterator_type>::value_type value_type;
#if !defined(BOOST_NO_RVALUE_REFERENCES) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
typedef value_type && reference;
#else
typedef typename ::boost::mpl::if_
< ::BOOST_MOVE_NAMESPACE::is_movable<value_type>
, ::BOOST_MOVE_NAMESPACE::rv<value_type>&
, value_type & >::type reference;
#endif
typedef It pointer;
typedef typename std::iterator_traits<iterator_type>::difference_type difference_type;
typedef typename std::iterator_traits<iterator_type>::iterator_category iterator_category;
move_iterator()
{}
explicit move_iterator(It i)
: m_it(i)
{}
template <class U>
move_iterator(const move_iterator<U>& u)
: m_it(u.base())
{}
iterator_type base() const
{ return m_it; }
reference operator*() const
{
#if defined(BOOST_NO_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
return *m_it;
#else
return ::BOOST_MOVE_NAMESPACE::move(*m_it);
#endif
}
pointer operator->() const
{ return m_it; }
move_iterator& operator++()
{ ++m_it; return *this; }
move_iterator<iterator_type> operator++(int)
{ move_iterator<iterator_type> tmp(*this); ++(*this); return tmp; }
move_iterator& operator--()
{ --m_it; return *this; }
move_iterator<iterator_type> operator--(int)
{ move_iterator<iterator_type> tmp(*this); --(*this); return tmp; }
move_iterator<iterator_type> operator+ (difference_type n) const
{ return move_iterator<iterator_type>(m_it + n); }
move_iterator& operator+=(difference_type n)
{ m_it += n; return *this; }
move_iterator<iterator_type> operator- (difference_type n) const
{ return move_iterator<iterator_type>(m_it - n); }
move_iterator& operator-=(difference_type n)
{ m_it -= n; return *this; }
reference operator[](difference_type n) const
{
#if defined(BOOST_NO_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
return m_it[n];
#else
return ::BOOST_MOVE_NAMESPACE::move(m_it[n]);
#endif
}
friend bool operator==(const move_iterator& x, const move_iterator& y)
{ return x.base() == y.base(); }
friend bool operator!=(const move_iterator& x, const move_iterator& y)
{ return x.base() != y.base(); }
friend bool operator< (const move_iterator& x, const move_iterator& y)
{ return x.base() < y.base(); }
friend bool operator<=(const move_iterator& x, const move_iterator& y)
{ return x.base() <= y.base(); }
friend bool operator> (const move_iterator& x, const move_iterator& y)
{ return x.base() > y.base(); }
friend bool operator>=(const move_iterator& x, const move_iterator& y)
{ return x.base() >= y.base(); }
friend difference_type operator-(const move_iterator& x, const move_iterator& y)
{ return x.base() - y.base(); }
friend move_iterator operator+(difference_type n, const move_iterator& x)
{ return move_iterator(x.base() + n); }
private:
It m_it;
};
//is_move_iterator
namespace move_detail {
template <class I>
struct is_move_iterator
: public ::boost::mpl::bool_<false>
{
};
template <class I>
struct is_move_iterator< ::BOOST_MOVE_NAMESPACE::move_iterator<I> >
: public ::boost::mpl::bool_<true>
{
};
} //namespace move_detail {
//////////////////////////////////////////////////////////////////////////////
//
// move_iterator
//
//////////////////////////////////////////////////////////////////////////////
//!
//! <b>Returns</b>: move_iterator<It>(i).
template<class It>
move_iterator<It> make_move_iterator(const It &it)
{ return move_iterator<It>(it); }
//////////////////////////////////////////////////////////////////////////////
//
// back_move_insert_iterator
//
//////////////////////////////////////////////////////////////////////////////
//! A move insert iterator that move constructs elements at the
//! back of a container
template <typename C> // C models Container
class back_move_insert_iterator
: public std::iterator<std::output_iterator_tag, void, void, void, void>
{
C* container_m;
public:
typedef C container_type;
explicit back_move_insert_iterator(C& x) : container_m(&x) { }
back_move_insert_iterator& operator=(typename C::reference x)
{ container_m->push_back(BOOST_MOVE_NAMESPACE::move(x)); return *this; }
back_move_insert_iterator& operator*() { return *this; }
back_move_insert_iterator& operator++() { return *this; }
back_move_insert_iterator& operator++(int) { return *this; }
};
//!
//! <b>Returns</b>: back_move_insert_iterator<C>(x).
template <typename C> // C models Container
inline back_move_insert_iterator<C> back_move_inserter(C& x)
{
return back_move_insert_iterator<C>(x);
}
//////////////////////////////////////////////////////////////////////////////
//
// front_move_insert_iterator
//
//////////////////////////////////////////////////////////////////////////////
//! A move insert iterator that move constructs elements int the
//! front of a container
template <typename C> // C models Container
class front_move_insert_iterator
: public std::iterator<std::output_iterator_tag, void, void, void, void>
{
C* container_m;
public:
typedef C container_type;
explicit front_move_insert_iterator(C& x) : container_m(&x) { }
front_move_insert_iterator& operator=(typename C::reference x)
{ container_m->push_front(BOOST_MOVE_NAMESPACE::move(x)); return *this; }
front_move_insert_iterator& operator*() { return *this; }
front_move_insert_iterator& operator++() { return *this; }
front_move_insert_iterator& operator++(int) { return *this; }
};
//!
//! <b>Returns</b>: front_move_insert_iterator<C>(x).
template <typename C> // C models Container
inline front_move_insert_iterator<C> front_move_inserter(C& x)
{
return front_move_insert_iterator<C>(x);
}
//////////////////////////////////////////////////////////////////////////////
//
// insert_move_iterator
//
//////////////////////////////////////////////////////////////////////////////
template <typename C> // C models Container
class move_insert_iterator
: public std::iterator<std::output_iterator_tag, void, void, void, void>
{
C* container_m;
typename C::iterator pos_;
public:
typedef C container_type;
explicit move_insert_iterator(C& x, typename C::iterator pos)
: container_m(&x), pos_(pos)
{}
move_insert_iterator& operator=(typename C::reference x)
{
pos_ = container_m->insert(pos_, ::BOOST_MOVE_NAMESPACE::move(x));
++pos_;
return *this;
}
move_insert_iterator& operator*() { return *this; }
move_insert_iterator& operator++() { return *this; }
move_insert_iterator& operator++(int) { return *this; }
};
//!
//! <b>Returns</b>: move_insert_iterator<C>(x, it).
template <typename C> // C models Container
inline move_insert_iterator<C> move_inserter(C& x, typename C::iterator it)
{
return move_insert_iterator<C>(x, it);
}
//////////////////////////////////////////////////////////////////////////////
//
// move
//
//////////////////////////////////////////////////////////////////////////////
//! <b>Effects</b>: Moves elements in the range [first,last) into the range [result,result + (last -
//! first)) starting from first and proceeding to last. For each non-negative integer n < (last-first),
//! performs *(result + n) = ::boost::move (*(first + n)).
//!
//! <b>Effects</b>: result + (last - first).
//!
//! <b>Requires</b>: result shall not be in the range [first,last).
//!
//! <b>Complexity</b>: Exactly last - first move assignments.
template <typename I, // I models InputIterator
typename O> // O models OutputIterator
O move(I f, I l, O result)
{
while (f != l) {
*result = ::BOOST_MOVE_NAMESPACE::move(*f);
++f; ++result;
}
return result;
}
//////////////////////////////////////////////////////////////////////////////
//
// move_backward
//
//////////////////////////////////////////////////////////////////////////////
//! <b>Effects</b>: Moves elements in the range [first,last) into the range
//! [result - (last-first),result) starting from last - 1 and proceeding to
//! first. For each positive integer n <= (last - first),
//! performs *(result - n) = ::boost::move(*(last - n)).
//!
//! <b>Requires</b>: result shall not be in the range [first,last).
//!
//! <b>Returns</b>: result - (last - first).
//!
//! <b>Complexity</b>: Exactly last - first assignments.
template <typename I, // I models BidirectionalIterator
typename O> // O models BidirectionalIterator
O move_backward(I f, I l, O result)
{
while (f != l) {
--l; --result;
*result = ::BOOST_MOVE_NAMESPACE::move(*l);
}
return result;
}
//////////////////////////////////////////////////////////////////////////////
//
// uninitialized_move
//
//////////////////////////////////////////////////////////////////////////////
//! <b>Effects</b>:
//! \code
//! for (; first != last; ++result, ++first)
//! new (static_cast<void*>(&*result))
//! typename iterator_traits<ForwardIterator>::value_type(boost::move(*first));
//! \endcode
//!
//! <b>Returns</b>: result
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F uninitialized_move(I f, I l, F r
/// @cond
,typename enable_if<is_movable<typename std::iterator_traits<I>::value_type> >::type* = 0
/// @endcond
)
{
typedef typename std::iterator_traits<I>::value_type input_value_type;
while (f != l) {
::new(static_cast<void*>(&*r)) input_value_type(BOOST_MOVE_NAMESPACE::move(*f));
++f; ++r;
}
return r;
}
/// @cond
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F uninitialized_move(I f, I l, F r,
typename disable_if<is_movable<typename std::iterator_traits<I>::value_type> >::type* = 0)
{
return std::uninitialized_copy(f, l, r);
}
//////////////////////////////////////////////////////////////////////////////
//
// uninitialized_copy_or_move
//
//////////////////////////////////////////////////////////////////////////////
namespace move_detail {
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F uninitialized_move_move_iterator(I f, I l, F r,
typename enable_if< is_movable<typename I::value_type> >::type* = 0)
{
return ::BOOST_MOVE_NAMESPACE::uninitialized_move(f, l, r);
}
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F uninitialized_move_move_iterator(I f, I l, F r,
typename disable_if< is_movable<typename I::value_type> >::type* = 0)
{
return std::uninitialized_copy(f.base(), l.base(), r);
}
} //namespace move_detail {
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F uninitialized_copy_or_move(I f, I l, F r,
typename enable_if< move_detail::is_move_iterator<I> >::type* = 0)
{
return ::BOOST_MOVE_NAMESPACE::move_detail::uninitialized_move_move_iterator(f, l, r);
}
//////////////////////////////////////////////////////////////////////////////
//
// copy_or_move
//
//////////////////////////////////////////////////////////////////////////////
namespace move_detail {
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F move_move_iterator(I f, I l, F r,
typename enable_if< is_movable<typename I::value_type> >::type* = 0)
{
return ::BOOST_MOVE_NAMESPACE::move(f, l, r);
}
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F move_move_iterator(I f, I l, F r,
typename disable_if< is_movable<typename I::value_type> >::type* = 0)
{
return std::copy(f.base(), l.base(), r);
}
} //namespace move_detail {
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F copy_or_move(I f, I l, F r,
typename enable_if< move_detail::is_move_iterator<I> >::type* = 0)
{
return ::BOOST_MOVE_NAMESPACE::move_detail::move_move_iterator(f, l, r);
}
/// @endcond
//! <b>Effects</b>:
//! \code
//! for (; first != last; ++result, ++first)
//! new (static_cast<void*>(&*result))
//! typename iterator_traits<ForwardIterator>::value_type(*first);
//! \endcode
//!
//! <b>Returns</b>: result
//!
//! <b>Note</b>: This function is provided because
//! <i>std::uninitialized_copy</i> from some STL implementations
//! is not compatible with <i>move_iterator</i>
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F uninitialized_copy_or_move(I f, I l, F r
/// @cond
,typename disable_if< move_detail::is_move_iterator<I> >::type* = 0
/// @endcond
)
{
return std::uninitialized_copy(f, l, r);
}
//! <b>Effects</b>:
//! \code
//! for (; first != last; ++result, ++first)
//! *result = *first;
//! \endcode
//!
//! <b>Returns</b>: result
//!
//! <b>Note</b>: This function is provided because
//! <i>std::uninitialized_copy</i> from some STL implementations
//! is not compatible with <i>move_iterator</i>
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F copy_or_move(I f, I l, F r
/// @cond
,typename disable_if< move_detail::is_move_iterator<I> >::type* = 0
/// @endcond
)
{
return std::copy(f, l, r);
}
//! If this trait yields to true
//! (<i>has_trivial_destructor_after_move <T>::value == true</i>)
//! means that if T is used as argument of a move construction/assignment,
//! there is no need to call T's destructor.
//! This optimization tipically is used to improve containers' performance.
//!
//! By default this trait is true if the type has trivial destructor,
//! every class should specialize this trait if it wants to improve performance
//! when inserted in containers.
template <class T>
struct has_trivial_destructor_after_move
: public ::boost::has_trivial_destructor<T>
{};
#ifndef BOOST_MOVE_DOXYGEN_INVOKED
#ifdef BOOST_MOVE_IN_BOOST_INTERPROCESS_NAMESPACE
#define BOOST_INTERPROCESS_ENABLE_MOVE_EMULATION(TYPE) BOOST_ENABLE_MOVE_EMULATION(TYPE)
#define BOOST_INTERPROCESS_MOVABLE_BUT_NOT_COPYABLE(TYPE) BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)
#define BOOST_INTERPROCESS_COPYABLE_AND_MOVABLE(TYPE) BOOST_COPYABLE_AND_MOVABLE(TYPE)
#define BOOST_INTERPROCESS_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2) BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)
#define BOOST_INTERPROCESS_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3) BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)
#define BOOST_INTERPROCESS_RV_REF(TYPE) BOOST_RV_REF(TYPE)
#define BOOST_INTERPROCESS_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE)
#define BOOST_INTERPROCESS_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2) BOOST_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)
#define BOOST_INTERPROCESS_COPY_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3) BOOST_COPY_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)
#define BOOST_INTERPROCESS_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
#define BOOST_INTERPROCESS_CATCH_CONST_RLVALUE(TYPE) BOOST_CATCH_CONST_RLVALUE(TYPE)
#endif
#define BOOST_MOVE_MACRO_ENABLE_MOVE_EMULATION(TYPE) BOOST_ENABLE_MOVE_EMULATION(TYPE)
#define BOOST_MOVE_MACRO_MOVABLE_BUT_NOT_COPYABLE(TYPE) BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)
#define BOOST_MOVE_MACRO_COPYABLE_AND_MOVABLE(TYPE) BOOST_COPYABLE_AND_MOVABLE(TYPE)
#define BOOST_MOVE_MACRO_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2) BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)
#define BOOST_MOVE_MACRO_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3) BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)
#define BOOST_MOVE_MACRO_RV_REF(TYPE) BOOST_RV_REF(TYPE)
#define BOOST_MOVE_MACRO_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE)
#define BOOST_MOVE_MACRO_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2) BOOST_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)
#define BOOST_MOVE_MACRO_COPY_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3) BOOST_COPY_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)
#define BOOST_MOVE_MACRO_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
#define BOOST_MOVE_MACRO_CATCH_CONST_RLVALUE(TYPE) BOOST_CATCH_CONST_RLVALUE(TYPE)
#endif //BOOST_MOVE_DOXYGEN_INVOKED
INTERPROCESS_NAMESPACE_END
} //namespace boost {
#endif //#ifndef BOOST_MOVE_HPP
|