Boost C++ Libraries: Ticket #11164: Graph adjacency_list, add_vertex compile error on clang 3.6 https://svn.boost.org/trac10/ticket/11164 <p> I have an issue similar to <a class="new ticket" href="https://svn.boost.org/trac10/ticket/10382" title="#10382: Bugs: 1.56.0 Graph adjacency_list has compile errors on g++ 4.6.4 (new)">#10382</a>. When compiling the following program </p> <pre class="wiki">#include &lt;boost/graph/adjacency_list.hpp&gt; struct Payload { Payload() = default; Payload(const Payload&amp;) {}; Payload&amp; operator=(const Payload&amp;) { return *this; }; }; struct PayloadD : public Payload { }; class Props { public: PayloadD payload; }; int main(int argc, char** argv) { using boost::adjacency_list; using boost::vecS; using boost::directedS; typedef adjacency_list&lt;vecS, vecS, directedS, Props&gt; Graph; Graph graph; boost::add_vertex(graph); return 0; } </pre><p> Using clang 3.6 I get the error message: </p> <pre class="wiki">/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/stl_construct.h:75:38: error: call to implicitly-deleted copy constructor of 'boost::detail::stored_edge_property&lt;unsigned long, boost::no_property&gt;' { ::new(static_cast&lt;void*&gt;(__p)) _T1(std::forward&lt;_Args&gt;(__args)...); } ... /usr/include/boost/graph/detail/adjacency_list.hpp:317:7: note: copy constructor is implicitly deleted because 'stored_edge_property&lt;unsigned long, boost::no_property&gt;' has a user-declared move constructor stored_edge_property(self&amp;&amp; x) = default; </pre><p> The same program compiles fine with gcc 4.8.2, 4.9.2, and clang 3.5. </p> <p> The attached patch changes stored_edge_property such that it always creates a custom copy constructor and copy assignment operator. With this changes clang 3.6 can build the program. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11164 Trac 1.4.3 dstoeckel@… Thu, 02 Apr 2015 21:22:58 GMT attachment set https://svn.boost.org/trac10/ticket/11164 https://svn.boost.org/trac10/ticket/11164 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fix_stored_edge_property.patch</span> </li> </ul> <p> Always declare a copy constructor and copy assignment operator. </p> Ticket anonymous Tue, 02 Feb 2016 17:20:48 GMT <link>https://svn.boost.org/trac10/ticket/11164#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11164#comment:1</guid> <description> <p> This patch seems obviously wrong. The type is supposed to be move-only, and tried to emulate that in C++03 with weird mutating auto_ptr-style copy operations. In C++11 that isn't needed because you can make the type move-only, but your patch would restore the weird not-really-a-copy-constructor. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 02 Feb 2016 18:18:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11164#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11164#comment:2</guid> <description> <p> Your Payload type needs to be nothrow-move-constructible, so that adding a vertex to the graph doesn't try to copy it, but moves it instead. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 03 Feb 2016 00:24:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11164#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11164#comment:3</guid> <description> <p> Ok, that explains a lot. In addition it needs to be remain default constructible, and if the containing adjacency list is copied also copy-assignable/constructible. This is also stated in the documentation: </p> <p> <a href="http://www.boost.org/doc/libs/1_60_0/libs/graph/doc/adjacency_list.html">http://www.boost.org/doc/libs/1_60_0/libs/graph/doc/adjacency_list.html</a>: </p> <p> <em>The types of all property values must be Copy Constructible, Assignable, and Default Constructible.</em> </p> <p> and also in practice: </p> <p> boost/graph/detail/adjacency_list.hpp:2156 </p> <pre class="wiki">m_vertices[v].m_property = x.m_vertices[i].m_property; </pre><p> The reason why I proposed the above patch was that I have a legacy C++98 code base that broke due to this requirement. Actually, every property requiring a custom copy-constructor/assignment operator should be hit by this. While this was fine before, now the full set of constructors/operators needs to be implemented... </p> <p> Fortunately, in my case adapting the code and sprinkling in some #ifdefs for older/non-standard platforms is unproblematical. </p> <p> However, to avoid confusion, the documentation should be updated to reflect the changed requirements. </p> </description> <category>Ticket</category> </item> </channel> </rss>