C++11 compatibility

This commit is contained in:
Matthias Koefferlein 2025-01-21 17:07:51 +01:00
parent 33b54f3f88
commit 2a47006a84
7 changed files with 87 additions and 21 deletions

View File

@ -2482,6 +2482,14 @@ struct array
return a;
}
/**
* @brief A dummy implementation of the "scaled" function for API compatibility
*/
array scaled (double f) const
{
return transformed (db::complex_trans<coord_type, coord_type> (f));
}
/**
* @brief Transformation of an array into a new system
*

View File

@ -203,7 +203,8 @@ public:
/**
* @brief Returns the scaled object
*/
auto scaled (double f) const
db::object_with_properties<typename tl::result_of_method<decltype (& Obj::scaled)>::type>
scaled (double f) const
{
return make_object_with_properties (Obj::scaled (f), m_id);
}
@ -212,7 +213,8 @@ public:
* @brief Returns the transformed object
*/
template <class Trans>
auto transformed (const Trans &tr) const
db::object_with_properties<typename tl::result_of_method<decltype (& Obj::template transformed<Trans>)>::type>
transformed (const Trans &tr) const
{
return make_object_with_properties (Obj::transformed (tr), m_id);
}
@ -304,20 +306,11 @@ typedef object_with_properties<db::array<db::CellInst, db::DTrans> > DCellInstAr
* @return t * obj
*/
template <class R>
struct result_of_method;
template <class R, class Obj, class A1>
struct result_of_method<R (Obj::*) (A1) const>
{
typedef R type;
};
template <class Tr, class Obj>
inline db::object_with_properties<typename result_of_method<decltype (& Obj::template transformed<Tr>)>::type>
inline db::object_with_properties<typename tl::result_of_method<decltype (& Obj::template transformed<Tr>)>::type>
operator* (const Tr &t, const db::object_with_properties<Obj> &obj)
{
return db::object_with_properties<typename result_of_method<decltype (& Obj::template transformed<Tr>)>::type> (obj.Obj::transformed (t), obj.properties_id ());
return db::object_with_properties<typename tl::result_of_method<decltype (& Obj::template transformed<Tr>)>::type> (obj.Obj::transformed (t), obj.properties_id ());
}
/**
@ -329,10 +322,10 @@ operator* (const Tr &t, const db::object_with_properties<Obj> &obj)
* @return The scaled object
*/
template <class Obj>
inline db::object_with_properties<typename result_of_method<decltype (& Obj::operator*)>::type>
inline db::object_with_properties<typename tl::result_of_method<decltype (& Obj::operator*)>::type>
operator* (const db::object_with_properties<Obj> &obj, double s)
{
return db::object_with_properties<typename result_of_method<decltype (& Obj::operator*)>::type> (obj * s, obj.properties_id ());
return db::object_with_properties<typename tl::result_of_method<decltype (& Obj::operator*)>::type> (obj * s, obj.properties_id ());
}
/**

View File

@ -1079,6 +1079,15 @@ struct path_ref
pref.transform (t);
return pref;
}
/**
* @brief A dummy implementation of the "scaled" function for API compatibility
*/
path_ref<Path, Trans> scaled (double) const
{
tl_assert (false); // not implemented
return *this;
}
};
/**

View File

@ -3522,6 +3522,15 @@ public:
pref.transform (t);
return pref;
}
/**
* @brief A dummy implementation of the "scaled" function for API compatibility
*/
polygon_ref<Poly, Trans> scaled (double) const
{
tl_assert (false); // not implemented
return *this;
}
};
/**

View File

@ -946,6 +946,15 @@ struct text_ref
tref.transform (t);
return tref;
}
/**
* @brief A dummy implementation of the "scaled" function for API compatibility
*/
text_ref<Text, Trans> scaled (double) const
{
tl_assert (false); // not implemented
return *this;
}
};
/**

View File

@ -24,6 +24,7 @@
#define HDR_dbPropertiesSupport
#include "gsiDecl.h"
#include "tlTypeTraits.h"
#include "dbPropertiesRepository.h"
#include "dbObjectWithProperties.h"
#include "dbTrans.h"
@ -75,10 +76,10 @@ static tl::Variant get_properties_meth_impl (const T *s)
}
template <class T>
static typename db::result_of_method<decltype (& T::scaled)>::type
static typename tl::result_of_method<decltype (& T::scaled)>::type
scaled_meth_impl (const T *s, double scale)
{
typename db::result_of_method<decltype (& T::scaled)>::type res (s->scaled (scale), s->properties_id ());
typename tl::result_of_method<decltype (& T::scaled)>::type res (s->scaled (scale), s->properties_id ());
return res;
}
@ -90,18 +91,18 @@ transformed_meth_impl0 (const T *s, const db::simple_trans<typename T::coord_typ
}
template <class T>
static typename db::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::DCoord> >)>::type
static typename tl::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::DCoord> >)>::type
transformed_meth_impl1 (const T *s, const db::complex_trans<typename T::coord_type, db::DCoord> &tr)
{
typename db::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::DCoord> >)>::type res (s->transformed (tr), s->properties_id ());
typename tl::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::DCoord> >)>::type res (s->transformed (tr), s->properties_id ());
return res;
}
template <class T>
static typename db::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::Coord> >)>::type
static typename tl::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::Coord> >)>::type
transformed_meth_impl2 (const T *s, const db::complex_trans<typename T::coord_type, db::Coord> &tr)
{
typename db::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::Coord> >)>::type res (s->transformed (tr), s->properties_id ());
typename tl::result_of_method<decltype (& T::template transformed<db::complex_trans<typename T::coord_type, db::Coord> >)>::type res (s->transformed (tr), s->properties_id ());
return res;
}

View File

@ -155,6 +155,43 @@ struct has_swap
static constexpr bool value = sizeof (__test_swap_func<T> (nullptr)) == sizeof (__yes_type);
};
/**
* @brief Delivers the return type for a method
*
* class Foo {
* int func(const std::string &s);
* };
*
* typedef typename tl::result_of_method<decltype (& Foo::func)>::type return_type; // int
*/
template <class R>
struct result_of_method;
template <class R, class Obj, class A1>
struct result_of_method<R (Obj::*) (A1) const>
{
typedef R type;
};
template <class R, class Obj, class A1, class A2>
struct result_of_method<R (Obj::*) (A1, A2) const>
{
typedef R type;
};
template <class R, class Obj, class A1, class A2, class A3>
struct result_of_method<R (Obj::*) (A1, A2, A3) const>
{
typedef R type;
};
template <class R, class Obj, class A1, class A2, class A3, class A4>
struct result_of_method<R (Obj::*) (A1, A2, A3, A4) const>
{
typedef R type;
};
}
#endif