graph-v2 icon indicating copy to clipboard operation
graph-v2 copied to clipboard

vertexist_iterator: has no member named ‘value_fn_’

Open rimmartin opened this issue 11 months ago • 3 comments

Hi,

After latest pull when including

#include "graph/views/vertexlist.hpp"

a compile yields:

In file included from src/bipartite_test.cpp:26:                                                                                                        
../cpp_modules/graph-v2/include/graph/views/vertexlist.hpp: In member function ‘constexpr graph::vertexlist_iterator<G, void>::value_type& graph::vertexlist_iterator<G, void>::operator*() const’:                                                                                                             
../cpp_modules/graph-v2/include/graph/views/vertexlist.hpp:167:36: error: ‘const class graph::vertexlist_iterator<G, void>’ has no member named ‘value_fn_’; did you mean ‘value_’? [-Wtemplate-body]                                                                                                           
  167 |       value_.shadow_.value = this->value_fn_(*iter_);                                                                                           
      |                                    ^~~~~~~~~                                                                                                    
      |                                    value_                                                                                                       
.

Otherwise I am having considerable success applying this project

rimmartin avatar Jan 04 '25 14:01 rimmartin

The problem lies here, I think, just the line of code compiler complained and the one above it:

/*114*/class vertexlist_iterator<G, void> {
//       ...
/*123*/  using vertex_value_type     = void;
//       ...
/*164*/  constexpr reference operator*() const {
/*165*/    value_.shadow_.vertex = &*iter_;
/*166*/    if constexpr (!is_void_v<vertex_value_type>)        // HERE
/*167*/      value_.shadow_.value = this->value_fn_(*iter_);   // HERE
/*168*/    return value_.value_;
/*169*/  }
//       ...
/*188*/};

value_fn_ is a member only other specializations of vertexlist_iterator have, and vertexlist_iterator<G, void> does not. So line 167 is essentially ill-formed. Then as we can see here, the constexpr condition !is_void_v<vertex_value_type> always evaluates to true. So in a template context, line 166 should cause compiler not to evaluate the code at line 167 (aka ignore it), thus making the program well-formed. However, somehow template magic disappeared from here, putting them in a non-template context, such context makes the compiler evaluates all branch code (even though it's if constexpr and branched code would never be executed), so it became an error. Just delete the two lines. They would never be executed anyway.

vspefs avatar Jan 08 '25 13:01 vspefs

Thank you. This project has great potential

rimmartin avatar Jan 08 '25 23:01 rimmartin

Thank you. This project has great potential

Yes. But it's really an on-going effort, so various bugs and errors can happen. There are also a few other problems, but nothing as tricky as this one.

vspefs avatar Jan 09 '25 04:01 vspefs