You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as i am seeking to reduce the compile times of our code, i am currently trying to reduce heavy includes in header files. For this, i am forward declaring function parameters as in this example:
// Class A.h
class B;
class A
{
...
void foo(B);
}
However, i did not find a way to forward declare our type definitions, that rely on boost units such as the definition of a length unit (Length.h) required as a function parameter in the file Object.h:
// Object.h
#include <Length.h> // This include shall be avoided
class Position;
class Object {
...
bool isNearby(Position pos, Length distance);
}
What I Tried:
I tried forward declaring the template boost::units::quantity<meter_unit, double>; but i struggeld to fwd-declare the meter_unit that contains both template class meter_base_unit and unit_type inside the namespace of meter_unit.
The meter_base_unit is defined inside boost units as below (simplified) and i guess the unit_type is defined inside the macro BOOST_TYPEOF_REGISTER_TYPE.
Is such a constellation even possible to forward declare completely?
I managed to forward declare the meter unit to some degree as shown here:
// MyBoostForwardDeclarations/Length_fwd.h
#include "boost/units/units_fwd.hpp"
#include <boost/units/base_units/si/meter.hpp>
namespace boost::units
{
template<class Unit, class Y> class quantity;
}
using meter_unit = boost::units::si::meter_base_unit::unit_type;
using Length = boost::units::quantity<meter_unit, double>;
However, this "forward declaration" header is still an expensive include because it need both units_fwd.hpp and meter.hpp
So therefore, i would prefer to completely forward declare the Length_Unit without including any boost header. Are there any ideas on how i could achieve this?
I am happy for every contribution regarding my specific problem and every contribution leading to deeper understanding of template forward declarations.
Thanks in Advance
SegfaultCreator
The text was updated successfully, but these errors were encountered:
Hello dear boost developers,
as i am seeking to reduce the compile times of our code, i am currently trying to reduce heavy includes in header files. For this, i am forward declaring function parameters as in this example:
However, i did not find a way to forward declare our type definitions, that rely on boost units such as the definition of a length unit (Length.h) required as a function parameter in the file Object.h:
What I Tried:
I tried forward declaring the template boost::units::quantity<meter_unit, double>; but i struggeld to fwd-declare the meter_unit that contains both template class meter_base_unit and unit_type inside the namespace of meter_unit.
The meter_base_unit is defined inside boost units as below (simplified) and i guess the unit_type is defined inside the macro BOOST_TYPEOF_REGISTER_TYPE.
Is such a constellation even possible to forward declare completely?
I managed to forward declare the meter unit to some degree as shown here:
However, this "forward declaration" header is still an expensive include because it need both units_fwd.hpp and meter.hpp
So therefore, i would prefer to completely forward declare the Length_Unit without including any boost header. Are there any ideas on how i could achieve this?
I am happy for every contribution regarding my specific problem and every contribution leading to deeper understanding of template forward declarations.
Thanks in Advance
SegfaultCreator
The text was updated successfully, but these errors were encountered: