6 #include <boost/type_traits.hpp> 7 #include <boost/utility/enable_if.hpp> 68 template <
typename TTo,
typename TFrom >
70 typename boost::enable_if_c<
72 boost::is_convertible<TFrom,TTo>::value
74 && !(std::numeric_limits<TFrom>::is_specialized || std::numeric_limits<TTo>::is_specialized)
75 && !is_same_naked<TFrom, TTo>::value
79 y =
static_cast<TTo
>(x);
85 template <
typename TTo,
typename TFrom >
94 template <
typename TTo,
typename TFrom >
96 typename boost::enable_if_c<
97 std::numeric_limits<TFrom>::is_specialized
98 && std::numeric_limits<TTo>::is_specialized
109 template <
typename T >
119 template <
typename T1,
typename T2 >
121 typename boost::enable_if<is_same_naked<T1,T2> >::type
130 template <
int D,
typename T1,
typename T2 >
134 for (
int i=0; i<D; ++i)
convert(x[i], y[i]);
139 inline void convert(
const Point3df & x, Point3df & y)
141 detail::convert_fixedLoop<3>(x,y);
147 template <
typename T1,
typename T2 >
155 template <
typename T1,
typename T2 >
166 template <
typename TTo,
typename TFrom >
179 template <
typename T,
typename B >
183 , std::vector<std::vector<std::pair<std::size_t, T> > > & v)
185 typedef std::vector<til::sparse_vector<T,B> > T1;
186 typedef std::vector<std::vector<std::pair<std::size_t, T> > > T2;
189 typename T1::const_iterator im = m.begin();
190 typename T2::iterator iv = v.begin();
191 for (; iv != v.end(); ++im, ++iv)
193 iv->resize(im->getMap().size());
194 typename T1::value_type::Map::const_iterator iim = im->getMap().begin();
195 typename T2::value_type::iterator iiv = iv->begin();
196 for (; iiv != iv->end(); ++iim, ++iiv)
void convert(TTo &x, const TFrom &y)
Belongs to package Box Do not include directly, include til/Box.h instead.
void operator()(const TFrom &x, TTo &y) const
TODO: The idea here is to have no convert with a loop; use for_each(..., Convert()) instead...
A class that mimic the behavior of std::vector but with a storage policy focused on sparse data...
void convert_allocate(std::vector< til::sparse_vector< T, B > > const &m, std::vector< std::vector< std::pair< std::size_t, T > > > &v)
void convert_fixedLoop(const T1 &x, T2 &y)
void operator()(const T1 &x, T2 &y) const
conversion between numerical types
TTo convertTo(const TFrom &x)
void convert_operatorEqual(const T &x, T &y)
void operator()(const T1 &x, T2 &y) const