小编Dor*_*ord的帖子

如何将包含多个参数的URL传递到URL?

基本上我正在尝试传递这样的URL:

www.foobar.com/?first=1&second=12&third=5
Run Code Online (Sandbox Code Playgroud)

进入这样的URL:

http://www.facebook.com/sharer.php?&t=FOOBAR&u=http://www.foobar.com/first=12&sec=25&position=2
Run Code Online (Sandbox Code Playgroud)

它只识别第一个参数.我在LinkedIn和Twitter分享方面遇到同样的问题,所以一定是我做错了.

html javascript query-parameters

47
推荐指数
2
解决办法
27万
查看次数

何时隐式移动构造函数不够好?

何时隐式移动构造函数不够好?

我应该把它当作析构函数和复制构造函数来对待它,通常只有在我管理自己的内存时才需要吗?

在这个(非常人为的)场景中隐式移动构造函数是否足够好:

class A
{
private:
    B b;
    std::string name;

public:
    A();
    std::string getName() const {
        return name;
    }

    B getB() const {
        return b;
    }
};

class B
{
private:
    std::vector list;

public: 
    B();
    std::vector getList() const {
        return list;
    }
};
Run Code Online (Sandbox Code Playgroud)

c++ move-semantics c++11

28
推荐指数
2
解决办法
1500
查看次数

使用SDL2调整无边框窗口大小时出错

我正在尝试使用SDL2中的无边框窗口创建应用程序.

我通过拖动实现了移动和调整大小.移动工作非常好.通过拖动底部和右边框来调整大小也很正常.

通过拖动顶部和左侧边框调整大小的功能很好,但它有一个装饰性的bug.

基本上,如果我从左边框拖动,窗口的右侧在移动时会产生很小的跳跃(可能是1-2个像素).从顶部边框拖动会导致底部跳跃.当我停止拖动窗口总是在正确的位置,但这个错误使它看起来非常不优雅.

该错误存在于Linux(多个WM/DE)和Windows上.我还没有在OS X上测试过.

我正在使用SDL_SetWindowPositionSDL_SetWindowSize.我试过绕过SDL并使用,XMoveResizeWindow但它会导致同样的错误.

虽然我强烈不想绕过SDL,但如果需要,我愿意使用Xlib和/或WinAPI.

这是我的代码片段:

// mousePos is initialized to current mouse pos
// newWindowSize initilized to current window size
// newWindowPos initialized to current window position
// mWindowResizeOffset variable is where the mouse grabbed the window

// omitted code for right and bottom borders because the bug doesn't exist there

// Logic for the top border is the same
if (mLeftBorderGrabbed)
{
    newWindowPos.x = mousePos.x - mWindowResizeOffset.x; …
Run Code Online (Sandbox Code Playgroud)

c++ x11 winapi sdl sdl-2

11
推荐指数
1
解决办法
2772
查看次数

在循环的条件语句中调用len()是否可以?

在C中,像这样调用strlen被认为是不好的做法:

for ( i = 0; strlen ( str ) != foo; i++ )
{
    // stuff
}
Run Code Online (Sandbox Code Playgroud)

当然,原因在于它效率低,因为它会多次"计算"字符串中的字符.

但是,在Python中,我经常看到这样的代码:

for i in range ( 0, len ( list ) ):
    # stuff
Run Code Online (Sandbox Code Playgroud)

这是不好的做法吗?我应该将len()的结果存储在变量中并使用它吗?

python arrays list

6
推荐指数
2
解决办法
1365
查看次数

标签 统计

c++ ×2

arrays ×1

c++11 ×1

html ×1

javascript ×1

list ×1

move-semantics ×1

python ×1

query-parameters ×1

sdl ×1

sdl-2 ×1

winapi ×1

x11 ×1