2
0
mirror of https://github.com/boostorg/mpi.git synced 2026-02-27 05:02:33 +00:00

Templated string serialization on the char type

[SVN r56138]
This commit is contained in:
Matthias Troyer
2009-09-10 15:22:21 +00:00
parent 4438c5850d
commit a8ada68d28
5 changed files with 12 additions and 8 deletions

View File

@@ -88,7 +88,8 @@ public:
load_impl(&t, sizeof(T));
}
void load( std::string & s)
template<class CharType>
void load(std::basic_string<CharType> & s)
{
unsigned int l;
load(l);

View File

@@ -79,7 +79,8 @@ public:
save_impl(&t, sizeof(T));
}
void save(const std::string &s)
template<class CharType>
void save(const std::basic_string<CharType> &s)
{
unsigned int l = static_cast<unsigned int>(s.size());
save(l);

View File

@@ -86,7 +86,8 @@ public:
load_impl(&t, get_mpi_datatype(t), 1);
}
void load( std::string & s)
template<class CharType>
void load(std::basic_string<CharType> & s)
{
unsigned int l;
load(l);
@@ -96,7 +97,7 @@ public:
#endif
s.resize(l);
// note breaking a rule here - could be a problem on some platform
load_impl(const_cast<char *>(s.data()),MPI_CHAR,l);
load_impl(const_cast<char *>(s.data()),get_mpi_datatype(CharType()),l);
}
private:

View File

@@ -77,11 +77,12 @@ public:
save_impl(&t, get_mpi_datatype<T>(t), 1);
}
void save(const std::string &s)
template<class CharType>
void save(const std::basic_string<CharType> &s)
{
unsigned int l = static_cast<unsigned int>(s.size());
save(l);
save_impl(s.data(),MPI_CHAR,s.size());
save_impl(s.data(),get_mpi_datatype(CharType()),s.size());
}
private:

View File

@@ -59,9 +59,9 @@ private:
* underlying MPI_Comm. This operation is used for "casting" from a
* communicator to an intercommunicator.
*/
explicit intercommunicator(const shared_ptr<MPI_Comm>& comm_ptr)
explicit intercommunicator(const shared_ptr<MPI_Comm>& cp)
{
this->comm_ptr = comm_ptr;
this->comm_ptr = cp;
}
public: