Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8749035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:37:38+00:00 2026-06-13T12:37:38+00:00

The following example compiles fine when using GCC 4.4.6 with the –std=c++0x flag but

  • 0

The following example compiles fine when using GCC 4.4.6 with the –std=c++0x flag but fails to compile in C++03 mode.

#include <stdint.h>
#include <boost/container/vector.hpp>

struct data
{
   int               i_;
   boost::container::vector<data>      v_;
};

int main( int argc, char** argv )
{
    data myData;
    myData.i_ = 10;

    data myData2;
    myData2.i_ = 30;

    myData.v_.push_back( myData2 );

    return 0;
}

It compiles successfully with

 g++ --std=c++0x test-cont.cpp

However if I remove the --std=c++0x I get the following errors:
g++ test-cont.cpp
In file included from
include/c++/4.4.6/memory:49,
boost/container/container_fwd.hpp:36,
boost/container/vector.hpp:20,
from test-cont.cpp:2:

include/c++/4.4.6/bits/stl_algobase.h: In static member function 
    static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::
        __copy_m(_II, _II, _OI) [with _II = 
            boost::container::constant_iterator<data, long int>, _OI = data*]:

include/c++/4.4.6/bits/stl_algobase.h:397:   instantiated from 
    _OI std::__copy_move_a(_II, _II, _OI) 
        [with bool _IsMove = false, 
                   _II = boost::container::constant_iterator<data, long int>, _OI = data*]

include/c++/4.4.6/bits/stl_algobase.h:436:   instantiated from 
    _OI std::__copy_move_a2(_II, _II, _OI) 
    [with bool _IsMove = false, 
               _II = boost::container::constant_iterator<data, long int>, _OI = data*]

include/c++/4.4.6/bits/stl_algobase.h:468:   instantiated from 
    _OI std::copy(_II, _II, _OI) 
        [with _II = boost::container::constant_iterator<data, long int>, _OI = data*]

boost/move/move.hpp:1147:   instantiated from 
    boost::copy_or_move(I, I, F, 
        typename boost::move_detail::disable_if< boost::move_detail::is_move_iterator<I>, void>::type*) 
        [with I = boost::container::constant_iterator<data, long int>, F = data*]

boost/container/detail/advanced_insert_int.hpp:58:   instantiated from 
    void boost::container::container_detail::advanced_insert_aux_proxy<A, FwdIt, Iterator>::copy_remaining_to(Iterator) 
    [with A = std::allocator<data>, FwdIt = boost::container::constant_iterator<data, long int>, Iterator = data*]

test-cont.cpp:21:   instantiated from here

include/c++/4.4.6/bits/stl_algobase.h:343: error: 
    no match for operator= in * __result = 
        __first.boost::container::constant_iterator<T, Difference>::operator* 
        [with T = data, Difference = long int]()

test-cont.cpp:5: note: candidates are: data& data::operator=(data&)

It looks like boost::container::vector requires move semantics which I assumed would automatically use boost::move when compiled with a c++03 compiler.

If I manually modify the struct data to define:

  1. a default constructor
  2. a copy constructor
  3. an assignment operator
  4. an emulated move constructor using BOOST_RV_REF
  5. an emulated move assignment operator using BOOST_RV_REF

The example compiles.

Having to manually add these move/copy constructors and assignment operators for C++03 is laborious.

Is this a bug with boost::container? If so what is the best way to report it to the boost community.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:37:39+00:00Added an answer on June 13, 2026 at 12:37 pm

    This is a limitation to the emulation in C++03 (from here):

    The macro BOOST_COPYABLE_AND_MOVABLE needs to define a copy
    constructor for copyable_and_movable taking a non-const parameter in
    C++03 compilers:

    //Generated by BOOST_COPYABLE_AND_MOVABLE
    copyable_and_movable &operator=(copyable_and_movable&){/**/}
    

    Since the non-const overload of the copy constructor is generated,
    compiler-generated assignment operators for classes containing
    copyable_and_movable will get the non-const copy constructor overload,
    which will surely surprise users.
    This limitation forces the user to define a const version of the copy
    assignment, in all classes holding copyable and movable classes which
    might annoying in some cases
    .

    In your case boost::container::vector<data> v_; uses BOOST_COPYABLE_AND_MOVABLE(vector) hence the error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This confuses me. The following compiles fine under Eclipse. package com.example.gotchas; public class GenericHelper1
The following example will not compile for me: #include <iostream> #include <functional> #include <string>
Ideally I want a function something like the following (this example doesn't compile): void
From the Scala API , I got the following example, which does not compile;
In following example: Line1 <br /> Line2 I'm using <br /> to force Line2
The following code doesn't compile with clang 3.1, using libc++ (don't know the version,
The following code compiles just fine, overwriting the values in v2 with those from
I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with
I have the following very simple application that compiles and runs fine: EDIT: changed
I have the following example, compiled in VS2005, warning level 4: int main(int argc,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.