我只想在Eclipse中设置一个新的GWT项目,并使用Maven来处理所有的jar丛林.我在这个指令中使用了gwt-maven-plugin ,但我无法让这个项目在Eclipse中运行.
我实际上做了什么:
gwt-maven-plugin:2.3.0-1:generateAsync - "No marketplace entries found to handle" gwt-maven-plugin:2.3.0-1:i18n - "No marketplace entries found to handle" gwt-maven-plugin:2.3.0-1:exploded - "No marketplace entries found to handle"
即使我在导入时忽略它们,这些错误也不会消失.
我怎样才能使这些项目有效?问题是我跳过了"process-resources"设置吗?(m2e的最新版本中没有这样的设置.)
我应该使用gwt-maven-plugin吗?还有其他方法可以让GWT项目使用Maven吗?或者 - 还有其他方法可以与jar丛林战斗吗?GWT家伙使用什么?
我使用Eclipse Indigo和m2e插件1.0.0以及Google套件插件版本2.3.3.
我想修改sqlalchemy设置以引发警告异常.
例如,当我在字段中插入的数据量大于定义的列长度时,mysql将截断数据,将截断的数据插入字段并发出警告.
而不是警告,我希望sqlalchemy代表mysql引发适当的错误.
>>> a = "?" # chinese
>>> b = unicode(a,"gb2312")
>>> a.__class__
<type 'str'>
>>> b.__class__
<type 'unicode'> # b is unicode
>>> a
'\xce\xd2'
>>> b
u'\u6211'
>>> c = u"?"
>>> c.__class__
<type 'unicode'> # c is unicode
>>> c
u'\xce\xd2'
Run Code Online (Sandbox Code Playgroud)
b并且c都是unicode,但>>> b输出u'\u6211'和>>> c输出u'\xce\xd2',为什么?
我遇到了一个有趣的观点,我无法解释或找到解释.考虑以下模板定义(使用mingw g ++ 4.6.2编译):
template <typename T, typename S>
class Foo
{
public:
void f(){}
void g(){}
};
Run Code Online (Sandbox Code Playgroud)
如果我们想要,我们可以完全专注于任何单一成员函数:
template <>
void Foo<char,int>::f() {}
Run Code Online (Sandbox Code Playgroud)
但部分特化失败,"无效使用不完整类型'类Foo <...>'"错误:
template <typename T, typename S>
void Foo<T,S*>::f()
{
}
template <typename T>
void Foo<T,int>::f()
{
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚原因.这是一个有意识的设计决策,以避免一些我无法预见的问题?这是疏忽吗?
提前致谢.
我想知道什么__cerb的意思libstdc++的g++,我发现,这似乎是一个简短的名称cerberos作为官方C++标准文档命名.
§22.3.1/ 3:
[示例:iostream
operator<<可能实现为:Run Code Online (Sandbox Code Playgroud)template <class charT, class traits> basic_ostream<charT,traits>& operator<< (basic_ostream<charT,traits>& s, Date d) { // !!!!!!!!!! typename basic_ostream<charT,traits>::sentry cerberos(s); // <--- !! HERE !! // !!!!!!!!!! if (cerberos) { ios_base::iostate err = ios_base::iostate::goodbit; tm tmbuf; d.extract(tmbuf); use_facet<time_put<charT,ostreambuf_iterator<charT,traits> > >( s.getloc()).put(s, s, s.fill(), err, &tmbuf, ’x’); s.setstate(err); // might throw } return s; }- 结束例子]
为什么sentry调用iostream 对象cerberos,cerberos实际意味着什么?
代码如下:
#include <iostream>
using namespace std;
class A {
};
A rtByValue() {
return A();
}
void passByRef(A &aRef) {
// do nothing
}
int main() {
A aa;
rtByValue() = aa; // compile without errors
passByRef(rtByValue()); // compile with error
return 0;
}
Run Code Online (Sandbox Code Playgroud)
g ++编译器给出以下错误:
d.cpp: In function ‘int main()’:
d.cpp:19:23: error: invalid initialization of non-const reference of type ‘A&’ from an rvalue of type ‘A’
d.cpp:12:6: error: in passing argument 1 of ‘void passByRef(A&)’
Run Code Online (Sandbox Code Playgroud)
它说我不能将rvalue作为非const引用的参数传递,但是我很困惑的是为什么我可以分配给这个rvalue,就像代码所示.
在游戏中,我想搜索项目地图并返回位于棋盘特定方块上的项目.但如果广场是空的怎么办?(这些项目没有存储在董事会结构中.对于这个问题,我没关系.)我有下面的代码,但是我应该怎样做才能返回"空"参考?
map<pair<int, int>, Item*> _items;
Item& itemAt(int row, int col) const {
try {
return *_items.at(make_pair(row, col));
} catch(out_of_range& e) {
return // what goes here?
}
}
Run Code Online (Sandbox Code Playgroud)
或者这是错误的方法,我应该使用find()?
我正在实现一个反向索引结构,特别是允许布尔查询和字级粒度的结构.
我有一个大型的文本数据库,我保留一个索引,告诉我,对于每个单词,它在哪个文件中(IDdoc),以及文件在哪里(position).(一个单词可以在许多文件中,也可以在一个文件中的许多位置.)
因此,我为每个单词保留一个向量:
vector<pair<IDdoc,position>> occurences_of_word;
Run Code Online (Sandbox Code Playgroud)
(向量按IDdoc排序,然后按位置按升序排序.)
我有一个string用文字构成的对象.这是我正在寻找的短语.
对于短语中的每个单词,我想知道哪些文档包含该短语,因此返回s 的向量.IDdoc
这是我尝试解决方案:
typedef std::string Word_t;
typedef unsigned int WordPosition_t;
typedef unsigned int IDdocument_t;
vector<pair<IDdocument_t,WordPosition_t> > IndiceInvertidoBooleanoConPosicion::_interseccion_dos_listas
(const vector<pair<IDdocument_t,WordPosition_t>> & v1,
const vector<pair<IDdocument_t,WordPosition_t>> & v2)
{
vector<pair<IDdocument_t,WordPosition_t> > intersection;
IDdocument_t ID_doc_one, ID_doc_two;
int i = 0;
int j = 0;
const int MAX_INDEX_V1 = v1.size() -1;
const int MAX_INDEX_V2 = v2.size() -1;
while(i <= MAX_INDEX_V1 && …Run Code Online (Sandbox Code Playgroud) 我对以下引用有疑问(N3797,3.9.1/8):
浮点类型的值表示是实现定义的.
据我所知,它为实现完全自由地定义了浮点数的边界.它们在中指定template<class T> class numeric_format.例如,
#include <iostream>
#include <limits>
int main()
{
std::cout << "double_max = " << std::numeric_limits<double>().max() << std::endl;
std::cout << "double_min = " << std::numeric_limits<double>().min() << std::endl;
std::cout << "float_max = " << std::numeric_limits<float>().max() << std::endl;
std::cout << "float_min = " << std::numeric_limits<float>().min() << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:浮点数的上下边界可以任意高或低,还是有限制?纯C是否还为浮点数提供了一组实现定义的值?
我怀疑这取决于我们正在使用的架构.
我有以下代码来查找最大值
int length = 2000;
float *data;
// data is allocated and initialized
float max = 0.0;
for(int i = 0; i < length; i++)
{
if(data[i] > max)
{
max = data;
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用SSE3内在函数进行矢量化,但我对如何进行比较感到震惊.
int length = 2000;
float *data;
// data is allocated and initialized
float max = 0.0;
// for time being just assume that length is always mod 4
for(int i = 0; i < length; i+=4)
{
__m128 a = _mm_loadu_ps(data[i]);
__m128 b = …Run Code Online (Sandbox Code Playgroud)