22 #ifndef POLYSCIP_SRC_GLOBAL_FUNCTIONS_H_INCLUDED 23 #define POLYSCIP_SRC_GLOBAL_FUNCTIONS_H_INCLUDED 31 #include <type_traits> 42 namespace impl_own_stl {
50 template<
typename T,
typename ... Args>
52 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
62 template<
typename T,
typename ... Args>
64 static_assert(std::extent<T>::value == 0,
65 "make_unique<T[N]>() is forbidden, please use make_unique<T[]>(),");
66 typedef typename std::remove_extent<T>::type U;
67 return std::unique_ptr<T>(
new U[
sizeof...(Args)]{std::forward<Args>(args)...});
79 template<
typename T,
typename ... Args>
81 return impl_own_stl::make_unique_helper<T>(
82 std::is_array<T>(),std::forward<Args>(args)... );
94 template<
typename Container>
95 void print(
const Container &container,
96 const std::string& prefix =
"",
97 const std::string& suffix =
"",
98 std::ostream &os = std::cout,
101 os << std::setprecision(prec) << prefix;
102 for (
const auto &elem : container)
118 template<
typename Target,
typename Source>
120 auto r =
static_cast<Target
>(v);
121 if (static_cast<Source>(
r)!=v)
122 throw std::runtime_error(
"narrow_cast<>() failed\n");
128 #endif //POLYSCIP_SRC_GLOBAL_FUNCTIONS_H_INCLUDED static SCIP_Real negate(SCIP_Real x)
Target narrow_cast(Source v)
std::unique_ptr< T > make_unique(Args &&... args)
std::unique_ptr< T > make_unique_helper(std::false_type, Args &&... args)
void print(const Container &container, const std::string &prefix="", const std::string &suffix="", std::ostream &os=std::cout, bool negate=false, int prec=6)