in_place_copy.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_CLI_IN_PLACE_COPY_HPP
14 #define MLPACK_BINDINGS_CLI_IN_PLACE_COPY_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace bindings {
20 namespace cli {
21 
30 template<typename T>
32  util::ParamData& /* d */,
33  const util::ParamData& /* input */,
34  const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
35  const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
36  const typename boost::disable_if<std::is_same<T,
37  std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
38 {
39  // Nothing to do.
40 }
41 
49 template<typename T>
51  util::ParamData& d,
52  const util::ParamData& input,
53  const typename std::enable_if<
54  arma::is_arma_type<T>::value ||
55  std::is_same<T,
56  std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value ||
57  data::HasSerialize<T>::value>::type* = 0)
58 {
59  // Make the output filename the same as the input filename.
60  typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
61  TupleType& tuple = *boost::any_cast<TupleType>(&d.value);
62  std::string& value = std::get<1>(tuple);
63 
64  const TupleType& inputTuple = *boost::any_cast<TupleType>(&input.value);
65  value = std::get<1>(inputTuple);
66 }
67 
76 template<typename T>
78  const void* input,
79  void* /* output */)
80 {
81  // Cast to the correct type.
82  InPlaceCopyInternal<typename std::remove_pointer<T>::type>(
83  const_cast<util::ParamData&>(d), *((const util::ParamData*) input));
84 }
85 
86 } // namespace cli
87 } // namespace bindings
88 } // namespace mlpack
89 
90 #endif
boost::any value
The actual value that is held.
Definition: param_data.hpp:82
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
void InPlaceCopyInternal(util::ParamData &, const util::ParamData &, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>>::type *=0)
This overload is called when nothing special needs to happen to make something an in-place copy...
void InPlaceCopy(const util::ParamData &d, const void *input, void *)
Make the given ParamData be an in-place copy of the input.