Opened 13 years ago

Closed 12 years ago

#3438 closed Bugs (wontfix)

node algorithms not usable with custom pointer types

Reported by: anonymous Owned by: Ion Gaztañaga
Milestone: Boost 1.41.0 Component: intrusive
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

throughout the node algorithms, especially the tree algorithms, node_ptr's are constructed using node_ptr(0). not all pointer types are constructible from 0. the default constructor, node_ptr(), should be used. a patch is attached.

Attachments (1)

intrusive.patch (2.4 KB ) - added by anonymous 13 years ago.
patch. replaces every instance of node_ptr(0) with node_ptr()

Download all attachments as: .zip

Change History (6)

by anonymous, 13 years ago

Attachment: intrusive.patch added

patch. replaces every instance of node_ptr(0) with node_ptr()

comment:1 by anonymous, 13 years ago

my patch somehow wasn't created recursively, so files in intrusive/detail/* aren't included. please change those files manually.

comment:2 by Ion Gaztañaga, 13 years ago

Why shouldn't be constructible from 0? A smart pointer that wants to be like a raw pointer should support 0 initialization.

comment:3 by anonymous, 13 years ago

why should it be constructible from 0? I know that the intrusive containers are only supposed to support certain types of pointers as their VoidPointer, but the algorithms don't have that restriction. not all pointer types want to be like raw pointers and are constructible from raw pointers. in fact, shared_ptr is not constructible from 0. (just an example, I'm not trying to use shared_ptrs). it does accept raw pointers, but not 0, as a template<class Y> shared_ptr(Y *) is not instantiated for 0.

and the node algorithms can go far beyond using pointers. e.g. you could use file offsets as pointer types, with 0 being a valid offset, to build a tree that resides in a file. and it's a very easy fix with no downsides.

comment:4 by anonymous, 13 years ago

unfortunately, there are more (and bigger) problems like that: e.g. tree_algorithms.hpp:143:

static node_ptr uncast(const_node_ptr ptr) {

return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));

}

why do you even have to typedef node_ptr in the node traits, when it's later assumed that node_ptr is castable to (node *)? I've seen that you offer the possibility of an ADL overload, but unfortunately that's still a dealbreaker. I can't convert my pointer type to a raw pointer.

can you explain to me what's the rational behind accepting const_node_ptr's in the tree_algorithms interface and then const-casting it all the time?

circular_list_algorithms doesn't have these problems, my linked list using the same pointer type works just fine.

comment:5 by Ion Gaztañaga, 12 years ago

Resolution: wontfix
Status: newclosed

This feature request won't be supported since it requires massive reworking.

Note: See TracTickets for help on using tickets.