0

I have this piece of code below :

in component_storage class :

    template < typename T, typename... Args >
    T& append( int index, Args&&... args )
    {
        grow();
        T* result = (T*)m_data + m_size - 1;
        construct_object<T>( result, std::forward<Args>( args )... );
        if ( m_indices )
            m_indices[ m_size - 1 ] = index;
        return *result;
    }

in component class :

    template < typename Component, typename ...Args >
    Component& add_component( handle h, Args&&... args )
    {
        component_interface* ci = get_interface<Component>();
        auto* cs = get_storage<Component>();
        int i = ci->m_index->insert( h );
        assert( i == int( cs->size() ) && "Fail!" );
        return cs->append<Component>( h.index, std::forward<Args>( args )... );
    }

and I call add_component in main like this:

    game_ecs e;
    e.register_component< position >();
    e.register_system< position_system >();

    handle being = e.create();
    e.add_component< position >( being, 3, 4 );

the problem is that I get those 2 errors :

 error: expected primary-expression before ‘>’ token
   return cs->append<Component>( h.index, std::forward<Args>( args )... );

error: expected binary operator before ‘)’ token
   return cs->append<Component>( h.index, std::forward<Args>( args )... );

I am Compiling under Linux with g++ 7.2 with C++17 flags enabled. Any suggestions on this errors? I cannot find any solution.

pureofpure
  • 1,060
  • 2
  • 12
  • 31
  • `cs->template append(..)` – Jarod42 Feb 15 '18 at 13:07
  • @Jarod42 oh god that's actually worked, this issue happens only with GCC compilers? because I don't have the same error with mvsc . – pureofpure Feb 15 '18 at 13:08
  • @pureofpure MSVC has had non-compliant templates without two-phase lookup since forever. One of the side effects is that `template` and `typename` as dependent name disambiguators are ignored. – Quentin Feb 15 '18 at 13:14

0 Answers0