OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
meta_copy< T > Struct Template Reference

This class copy general objects. More...

Detailed Description

template<typename T>
struct meta_copy< T >

This class copy general objects.

  • primitives
  • array of primitives
  • complex objects
  • aggregates

Usage of meta copy and compare for primitives

float f_src = 1.0;
float f_dst;
meta_copy<float>(f_src,f_dst);
BOOST_REQUIRE_EQUAL(f_src,f_dst);
bool ret = meta_compare<float>::meta_compare_f(f_src,f_dst);
BOOST_REQUIRE_EQUAL(ret,true);

Usage of meta copy and compare for array of primitives

float f_src[2][3] = {{1.0,2.9,4.0},{2.3,4.4,9.0}};
float f_dst[2][3];
meta_copy<float[2][3]>(f_src,f_dst);
BOOST_REQUIRE_EQUAL(ret,true);

Usage of meta copy and compare for openfpm aggregates

boost::fusion::at_c<0>(agg1.data) = 1.0;
boost::fusion::at_c<1>(agg1.data) = 2.0;
boost::fusion::at_c<2>(agg1.data)[0] = 3.0;
boost::fusion::at_c<2>(agg1.data)[1] = 4.0;
boost::fusion::at_c<2>(agg1.data)[2] = 5.0;
bool ret = meta_compare<aggregate<float,int,float[3]>>::meta_compare_f(agg1,agg2);
BOOST_REQUIRE_EQUAL(ret,true);

Usage of meta copy and compare for complex object

std::string s_src("Test string");
std::string s_dst;
meta_copy<std::string>(s_src,s_dst);
BOOST_REQUIRE_EQUAL(s_src,s_dst);
BOOST_REQUIRE_EQUAL(ret,true);

Usage of meta copy and compare for complex aggregates object

aggregate<std::string,std::vector<float>,std::map<size_t,std::string>,std::string[3]> a_src;
// fill the complex aggregates
a_src.template get<0>() = std::string("Test string");
a_src.template get<1>().push_back(5.0);
a_src.template get<1>().push_back(15.0);
a_src.template get<1>().push_back(45.0);
a_src.template get<1>().push_back(7.0);
a_src.template get<2>()[0] = std::string("Test string 2");
a_src.template get<2>()[10] = std::string("Test string 3");
a_src.template get<2>()[9] = std::string("Test string 4");
a_src.template get<2>()[1] = std::string("Test string 5");
a_src.template get<3>()[0] = std::string("Last string 9");
a_src.template get<3>()[1] = std::string("Last string 10");
a_src.template get<3>()[2] = std::string("Last string 11");
aggregate<std::string,std::vector<float>,std::map<size_t,std::string>,std::string[3]> a_dst;
meta_copy<aggregate<std::string,std::vector<float>,std::map<size_t,std::string>,std::string[3]>>(a_src,a_dst);
bool ret = meta_compare<aggregate<std::string,std::vector<float>,std::map<size_t,std::string>,std::string[3]>>::meta_compare_f(a_src,a_dst);
BOOST_REQUIRE_EQUAL(ret,true);

Usage of meta copy and compare for Point_test

Definition at line 13 of file copy_compare_aggregates.hpp.

#include <meta_copy.hpp>

Public Member Functions

 meta_copy (const T &src, T &dst)
 

The documentation for this struct was generated from the following files: