我正在尝试调用int
向量的模板,但我没有找到解决以下错误的方法(我已查看网站上的建议问题):
D:\CodeBlocks\Tests\Templates\main.cpp|51|error: conversion from 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >' to non-scalar type 'std::vector<int>' requested|
Bellow这是我的代码:
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <functional>
template<typename C> C f(C x)
{
return x;
}
template <class A, class B> typename std::vector<B> my_map(A fct,B v)
{
int n = v.size();
std::vector<B> r(n);
int i;
for(i=0;i<n;i++)
{
r[i]=(B) fct(v[i]);
}
return r;
}
int main()
{
std::vector<int> mapvector {1,2,5,7,9};
std::vector<int> ret = my_map(&f<int>,mapvector);
std::copy(ret.begin(), ret.end(), std::ostream_iterator<int>(std::cout));
return 0;
}
答案 0 :(得分:1)
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth)
throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.passwordEncoder(passwordEncoder())
.usersByUsernameQuery("sql...")
.authoritiesByUsernameQuery("sql...");
}
@Bean
public PasswordEncoder passwordEncoder(){
PasswordEncoder encoder = new BCryptPasswordEncoder();
return encoder;
}