Ich versuche, die Art der Elemente zu beschränken, wie std::array<std::string,N>>
zu verarbeiten, aber Template Substitution nicht für N.Vorlage: Der Abzug von Array-Größe gescheitert
main.cpp:10:1: note: template argument deduction/substitution failed:
main.cpp:31:34: note: couldn't deduce template parameter 'N'
print(word.begin(),word.end());
Mein Versuch, wie folgend.
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <boost/range/iterator_range.hpp>
template<typename ForwardIterator,std::size_t N>
typename std::enable_if<std::is_same<typename ForwardIterator::value_type,std::array<std::string,N> >::value >::type
print(ForwardIterator begin, ForwardIterator end)
{
for(auto const & arr : boost::make_iterator_range(begin,end))
{
for(auto const & item : arr)
{
std::cout<<item<<' ';
}
std::cout<<'\n';
}
}
int main()
{
std::vector<std::array<std::string,2>> word;
word.push_back({{"hello","Hi"}});
word.push_back({{"b","bye"}});
print(word.begin(),word.end());
}
ist Danke ... Es hat funktioniert !! – gjha