Boost logo

Boost Users :

Subject: Re: [Boost-users] [container] Initialization from transformed_range compilation error
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2011-09-07 06:57:36


El 07/09/2011 0:05, Szymon Gatner escribió:

It's moved, this feature produces the limitation (must define
copy-constructor for copyable types owning copyable and movables classes
like boost::container::vector) that Daniel has suffered. Example:

#include <boost/container/vector.hpp>
#include <string>

struct template_symbol
{
    template_symbol(){}

    template_symbol(const template_symbol &x)
       : params(x.params)
    {}

    template_symbol& operator=(const template_symbol &x)
    {
       params = x.params;
       return *this;
    }

    boost::container::vector<std::string> params;
};

boost::container::vector<template_symbol> func()
{
    return boost::container::vector<template_symbol>();
}

int main()
{
    //RVO
    boost::container::vector<template_symbol> x (func());
    //Moved
    x = func();
    return 0;
}

I think I'd should add this info to container documentation.

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net