How to enter a single value in a vector of pair? - c++

I am trying out a project in C++ and I am trying to enter a value from an integer type vector to a pair type vector.
I have tried emplace_back and push_back but it doesn't work. Most probably due to the pair typed vector.
Note: I am using boost libraries, not sure if that is helpful.
typedef unsigned int objecttype;
typedef string operationtype;
typedef unsigned int checkob;
typedef pair<objecttype, operationtype> objectops;
vector<vector<unsigned int>> parameters;
//lines returning values to “parameters”
vector<checkob> checkParams = parameters.at(0); // works fine
vector<objectops> objectParams = parameters.at(1); // below error
The error message:
error test.cpp:273:30: error: no viable conversion from 'vector<unsigned int, allocator<unsigned int>>' to 'vector<model:: objectops, allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >>>'
stl_vector.h:326:7: note: candidate constructor not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::value_type' (aka 'std::vector<unsigned int, std::allocator<unsigned int> >') to 'const std::vector<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > &' for 1st argument
stl_vector.h:344:7: note: candidate constructor not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::value_type' (aka 'std::vector<unsigned int, std::allocator<unsigned int> >') to 'std::vector<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > &&' for 1st argument
stl_vector.h:383:7: note: candidate constructor not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::value_type' (aka 'std::vector<unsigned int, std::allocator<unsigned int> >') to 'initializer_list<std::vector<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::value_type>' (aka 'initializer_list<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >') for 1st argument

You are trying to assign std::vector<unsigned int> to std::pair<unsigned int, std::string>, which is obviously not possible.
You can either
assign a vector of std::pair<unsigned int, std::string> to
objectParams
or a list initialization using a pair of the element of the vector
of vector of unsigned int egers(i.e. unsigned int) of parameters
and a std::string.
You probably mean this:
vector<objectops> objectParams ={ { parameters.at(0).at(0), "string"} };
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ std::pair<objecttype, operationtype>
// ^^ ^^ for std::vector<objectops>

Related

Error assigning values to the nested map with tuple as its value

I been maintaining some statistics in a map, the below are my typedefs to create the map
typedef Time TOTALTIME,MINM,MAXM,AVRG;
typedef std::map<std::string,std::map<status,int>> RequestStatus;//status is an enum
typedef std::tuple<int,TOTALTIME,MINM,MAXM,AVRG,RequestStatus> Attributes ;
typedef std::map<std::string,Attributes> requestStatistics ;
requestStatistics sampleStruct //my final map
And i have been initializing like
sampleStruct.insert(make_pair(someskey,std::make_tuple(1,TOTALTIME(),MINM(),MAXM(),AVRG(),sampleStatus[functionName][status::READY]=1)));
other way I have tried
sampleStruct[somekey]=std::make_tuple(1,TOTALTIME(),MINM(),MAXM(),AVRG(),sampleStatus[functionName][status::READY]=1)
Both doesn't pass the compiler always endup in compile error, lemme put out some compile error I,ve got
std::map<endstor::Data::statistics::status, int, std::less<endstor::Data::statistics::status>, std::allocator<std::pair<const endstor::Data::statistics::status, int> > >,
std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<endstor::Data::statistics::status, int, std::less<endstor::Data::statistics::status>, std::allocator<std::pair<const endstor::Data::statistics::status, int> > > > > > > > >]
insert(const_iterator __position, _Pair&& __x)
1)was the structure I've created is valid?were the assignments are ok?
The last parameter in your insert or make_tuple calls is sampleStatus[functionName][status::READY]=1, which is an int, while the tuple is expecting a RequestStatus. This type difference would be the cause of your error.

Passing arguments to constructor results in an error

I have a constructor which constructs a matrix, represented by a 2D vector, rows and columns number.
Matrix(const vector<vector<T> >* vect, const size_t rows, const size_t cols) :
matrix(&vect), matrixRows(rows), matrixCols(cols){}
I want to find the transpose of a matrix in one of my functions.
Matrix& trans() const
{
vector<vector<T> > trans(matrixCols, vector<T>(matrixRows));
for(unsigned int i = 0; i < matrixRows; i++)
{
for(unsigned int j = 0; j < matrixCols; j++)
{
trans[j][i] = matrix[i][j];
}
}
return Matrix(&trans, matrixCols, matrixRows);
}
The last line results in an error, because passing a vector this way is wrong.
What is the correct way?
Full error:
Multiple markers at this line
- invalid initialization of non-const reference of type 'Matrix<Complex>&' from an rvalue of type
'Matrix<Complex>'
- required from 'Matrix<T>& Matrix<T>::trans() const [with T = int]'
- invalid initialization of non-const reference of type 'Matrix<double>&' from an rvalue of type
'Matrix<double>'
- invalid initialization of non-const reference of type 'Matrix<int>&' from an rvalue of type 'Matrix<int>'
- required from 'Matrix<T>& Matrix<T>::trans() const [with T = Complex]'
- required from 'Matrix<T>& Matrix<T>::trans() const [with T = double]'
constructor error:
Multiple markers at this line
- invalid conversion from 'const std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >**' to 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >::size_type
{aka long long unsigned int}' [-fpermissive]
- candidate expects 3 arguments, 1 provided
- no matching function for call to 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >::vector(const std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > >
>**)'
- no known conversion for argument 1 from 'std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >' to 'const std::vector<std::vector<double, std::allocator<double> >,
std::allocator<std::vector<double, std::allocator<double> > > >*'
- candidate: Matrix<T>::Matrix(const std::vector<std::vector<T> >*, size_t, size_t) [with T = double; size_t = long long unsigned int]
- no known conversion for argument 1 from 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >' to 'const std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int>
> > >*'
- candidate: Matrix<T>::Matrix(const std::vector<std::vector<T> >*, size_t, size_t) [with T = int; size_t = long long unsigned int]
- no matching function for call to 'std::vector<std::vector<Complex, std::allocator<Complex> >, std::allocator<std::vector<Complex, std::allocator<Complex> > > >::vector(const std::vector<std::vector<Complex, std::allocator<Complex> >,
std::allocator<std::vector<Complex, std::allocator<Complex> > > >**)'
- invalid conversion from 'const std::vector<std::vector<Complex, std::allocator<Complex> >, std::allocator<std::vector<Complex, std::allocator<Complex> > > >**' to 'std::vector<std::vector<Complex, std::allocator<Complex> >,
std::allocator<std::vector<Complex, std::allocator<Complex> > > >::size_type {aka long long unsigned int}' [-fpermissive]
- no matching function for call to 'std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >::vector(const std::vector<std::vector<double, std::allocator<double> >,
std::allocator<std::vector<double, std::allocator<double> > > >**)'
- invalid conversion from 'const std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >**' to 'std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double,
std::allocator<double> > > >::size_type {aka long long unsigned int}' [-fpermissive]
- no known conversion for argument 1 from 'std::vector<std::vector<Complex, std::allocator<Complex> >, std::allocator<std::vector<Complex, std::allocator<Complex> > > >' to 'const std::vector<std::vector<Complex, std::allocator<Complex> >,
std::allocator<std::vector<Complex, std::allocator<Complex> > > >*'
- candidate: Matrix<T>::Matrix(const std::vector<std::vector<T> >*, size_t, size_t) [with T = Complex; size_t = long long unsigned int]
First off, you probably want the Matrix constructor to take the vector by reference instead of address:
Matrix(const vector<vector<T>>& vect, const size_t rows, const size_t cols)
: matrix(vect), matrixRows(rows), matrixCols(cols)
{
}
(Note that this will cause the vector to be copied into matrix. Depending on the size of the vector, this might be fine - it really depends on the performance requirements of your program.)
Secondly, trans() should not return a reference to a Matrix. Since you are returning the value of a local, the variable will be destroyed when execution leaves the function, so the caller would have no way to make use of it.
Combined with the change to the Matrix constructor above, trans() should compile now:
Matrix trans() const
{
vector<vector<T>> trans(matrixCols, vector<T>(matrixRows));
for(unsigned int i = 0; i < matrixRows; i++)
{
for(unsigned int j = 0; j < matrixCols; j++)
{
trans[j][i] = matrix[i][j];
}
}
return Matrix(trans, matrixCols, matrixRows);
}

error: '__pred' cannot be used as a function

I can't find what I'm doing wrong here. The function eta does what I ask but when I use it in the loop I get the attached error.
bool eta(map<string, TLorentzVector> map_jets, string jet){
return( fabs(map_jets[jet].PseudoRapidity()) > 2.5 );
}
and then
vector<pair<string,double> > jets_pt( vec_jets.size() );
for( vector<pair<string,double> >::iterator it = jets_pt.begin(); it != jets_pt.end(); ++it)
jets_pt.erase(remove_if(jets_pt.begin(),jets_pt.end(),eta(map_jets,it1->first)),jets_pt.end);
I get the error
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h: In function '_OutputIterator std::remove_copy_if(_InputIterator, _InputIterator, _OutputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>*, std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> > > >, _OutputIterator = __gnu_cxx::__normal_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>*, std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> > > >, _Predicate = bool]':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:1291: instantiated from '_ForwardIterator std::remove_if(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>*, std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> > > >, _Predicate = bool]'
/misc/cdf/gbertoli/hww/Diboson_v20_taus/Ana/src/Functions.cc:25: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:1216: error: '__pred' cannot be used as a function
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h: In function '_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>*, std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> > > >, _Predicate = bool]':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:338: instantiated from '_InputIterator std::find_if(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>*, std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> > > >, _Predicate = bool]'
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:1287: instantiated from '_ForwardIterator std::remove_if(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>*, std::vector<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double>, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> > > >, _Predicate = bool]'
/misc/cdf/gbertoli/hww/Diboson_v20_taus/Ana/src/Functions.cc:25: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:260: error: '__pred' cannot be used as a function
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:264: error: '__pred' cannot be used as a function
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:268: error: '__pred' cannot be used as a function
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:272: error: '__pred' cannot be used as a function
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:280: error: '__pred' cannot be used as a function
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:284: error: '__pred' cannot be used as a function
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:288: error: '__pred' cannot be used as a function
mv: cannot stat `/misc/cdf/gbertoli/hww/Diboson_v20_taus/tmp/Linux2.6-GCC_4_1/Ana/srt_dep_tmp.27294': No such file or directory
gmake[2]: *** [/misc/cdf/gbertoli/hww/Diboson_v20_taus/tmp/Linux2.6-GCC_4_1/Ana/libAna-shared/Functions.o] Error 1
gmake[1]: *** [src.lib] Error 2
gmake: *** [Ana.all] Error 2
First off, the only valid signature for remove_if takes a single function as the predicate argument:
jets_pt.erase(std::remove_if(jets_pt.begin(), jets_pt.end(), eta),
jets_pt.end());
This means that eta must be a function returning bool and taking precisely one argument whose type is the value type of the container:
bool eta(const std::pair<string, double> & p)
{
// do something useful with p
}
If this doesn't fit your bill because you need additional state information in the predicate, then you need to make it a function object:
struct Eta
{
const std::map<string, TLorentzVector> & map_jets;
Eta(const std::map<string, TLorentzVector> & m) : map_jets(m) { }
bool operator()(const std::pair<string, double> & p) const
{
std::map<string, TLorentzVector>::const_iterator it = map_jets.find(p->second);
return it == map_jets.end() ?
false :
std::fabs(it->second.PseudoRapidity()) > 2.5;
}
};
Now you have to use remove_if with an instance of Eta:
jets_pt.erase(std::remove_if(jets_pt.begin(), jets_pt.end(), Eta(map_jets)),
jets_pt.end()); // ^^^^^^^^^^^^^
Note that your use of the for loop is extremely suspicious; you should double-check that.
std::remove_if takes a value of the contained type (bool pred (container::value_type), or a functor which overloads operator() appropriately).
For std::map, you have to do it like explained here remove_if equivalent for std::map .
You're passing a bool (the results of calling eta) to remove_if as
the third argument. You need to pass it a predicate: a pointer to a
function taking a single argument and returning something which can be
converted to a bool, or a functional object. In the error messages,
__pred is your third argument; remove_if calls it here with a
pair<string, double>, and expects a bool in return. You have to
provide something which can be called like this. (You might want to
look into boost::bind.)
And BTW: passing a map by value to eta might not be a good idea.
It's going to slow things down considerably if the map is big.

C++ Deep Copying a pointer to a map with pointer values

I am having a bit of trouble deep copying a pointer to a map of pointer values.
std::map<string, TH1D*>* m_hist_split;
My current method:
I am using a class template that copies the map pair and initializes the value of the pair on the heap. the template then returns a map::type_value
#ifndef DEEPCOPY_H
#define DEEPCOPY_H
#include <map>
#include <algorithm>
namespace DeepCopy{
template<class A, class B>
struct MapPointerValue{
typedef typename std::map< A, B* >::value_type map_t;
map_t operator() (map_t p){
return std::make_pair(p.first, new B(*p.second) );
}
};
...
...
}
#endif
Inside my copy constructor I then attempt to deep copy my pointer to a map of pointer values.
Cutflow::Cutflow(const Cutflow& cpy){
m_hist_split = new map<string, TH1D*>;
transform(cpy.m_hist_split->begin(),cpy.m_hist_split->end(), inserter(m_hist_split, m_hist_split->begin()), DeepCopy::MapPointerValue<string, TH1D>() );
...
...
}
When compiling I then get an ugly error :-( :
Compiling src/Cutflow.cxx to obj/Cutflow.o
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h: In instantiation of 'std::insert_iterator<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*>':
src/Cutflow.cxx:42: instantiated from here
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h:562: error: 'std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*' is not a class, struct, or union type
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h:572: error: 'std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*' is not a class, struct, or union type
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h:599: error: 'std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*' is not a class, struct, or union type
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h:608: error: 'std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*' is not a class, struct, or union type
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h: In function 'std::insert_iterator<_Container> std::inserter(_Container&, _Iterator) [with _Container = std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*, _Iterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> >]':
src/Cutflow.cxx:42: instantiated from here
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h:648: error: 'std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*' is not a class, struct, or union type
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_algo.h: In function '_OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation) [with _IIter = std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> >, _OIter = std::insert_iterator<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*>, _UnaryOperation = DeepCopy::MapPointerValue<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D>]':
src/Cutflow.cxx:42: instantiated from here
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_algo.h:4281: error: no match for 'operator=' in '__result.std::insert_iterator<_Container>::operator* [with _Container = std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*]() = DeepCopy::MapPointerValue<A, B>::operator()(typename std::map<A, B*, std::less<_Key>, std::allocator<std::pair<const A, B*> > >::value_type) [with A = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, B = TH1D](std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*>(((const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*>&)((const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*>*)__first.std::_Rb_tree_iterator<_Tp>::operator* [with _Tp = std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*>]()))))'
x86_64-slc5-gcc34-opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/stl_iterator.h:559: note: candidates are: std::insert_iterator<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*>& std::insert_iterator<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*>::operator=(const std::insert_iterator<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, TH1D*> > >*>&)
Any ideas what I am doing wrong.
Also,
is what I am doing correct?
:-D
In the following line
transform(cpy.m_hist_split->begin(),cpy.m_hist_split->end(), inserter(m_hist_split, m_hist_split->begin()), DeepCopy::MapPointerValue<string, TH1D>() );
you have mistakenly called the inserter function with a pointer to a map as the first parameter instead of a reference.
For completeness, inserter is defined in §24.5.2.6.5 like this:
template <class Container>
insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
Returns: insert_iterator(x, i)
In this case, a simple typo caused a big headache.

Unable to iterate through template map. How to deal with this error?

I have a graph class that employs two dimension vertices using a map with another map nested inside, as such(V is my template):
map< V , map< V , int> > vertices;
Defining an iterator as such seems to be ok:
typename map< V, map< V , int>::iterator i;
However when I try to use that iterator, like this i = vertices.begin() , I get a long error that looks like this. (main.cpp 81 is where I call the method that does the iteration). Where could I look at to find what's wrong?
main.cpp:81: instantiated from here
graph.h:326: error: no match for ‘operator=’ in ‘i = ((const GraphNameSpace::Graph<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)this)->GraphNameSpace::Graph<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::vertices.std::map<_Key, _Tp, _Compare, _Alloc>::begin [with _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Tp = std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > >, _Compare = std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > > > >]()’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_tree.h:152: note: candidates are: std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > > > >& std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > > > >::operator=(const std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > > > >&)
make: *** [main.o] Error 1
UPDATE:
At the risk of providing too much information, here is my graph class on pastebin. Right at the very bottom in the dump function is where I'm attempting to do the iteration.
The member function dump(), inside which you write i = vertices.begin(), is a const member function, which effectively makes vertices a const object, for it is a member of the class. So you need const_iterator:
typename map<V, map<V, int> >::const_iterator i;
//^^^^^ note this
It should work now. :-)