问题列表 - 第43085页

无法专门化功能模板

这是家庭作业,虽然已经提交了不同的方法.

我从Visual Studio 2008获得以下内容

error C2893: Failed to specialize function template 'void std::sort(_RanIt,_RanIt,_Pr)'

代码如下

main.cpp
    Database<> db; 
    db.loadDatabase();
    db.sortDatabase(sort_by_title());  

Database.cpp
void Database<C>::sortDatabase(const sort_by &s) { 
    std::sort(db_.begin(), db_.end(), s); 
}

并且函数对象被定义为

struct sort_by : public std::binary_function<const Media *, const Media *, bool> { 
    virtual bool operator()(const Media *l, const Media *r) const = 0;
};

struct sort_by_title : public sort_by {
    bool operator()(const Media *l, const Media *r) const { ... }
};
...

这里有什么治疗方法?

[编辑]对不起,也许我应该明确继承

template <typename C = std::vector<Media …

c++ inheritance functor specialization template-specialization

5
推荐指数
1
解决办法
3103
查看次数

如何在Linux shell中接受左/右/上/下箭头输入?

我编写了一个Java应用程序,它有一个while(input.readLine()),它继续读取输入,直到用户键入quit命令.我有一个.bat脚本在Windows中启动它,一个.sh在Linux中启动它.该应用程序在两者中都运行正常

在Windows中,如果您键入"check email"之类的命令并按Enter键,它将执行该命令.然后,在下一个提示符(即:下次Java应用程序读取输入行)时,您可以点击向上箭头,它会调用您的"检查电子邮件"命令.您可以按左箭头键向左移动光标等.这正是我想要的.

但是,在Linux上,按向上键会导致^ [[D出现.左右箭头键产生类似的ASCII输出,如^ [[C.

我听说过stty并查看了man页面,但是无法通过启动我的Java应用程序来弄清楚我需要在.sh脚本中进行更改.谁能帮我?

java linux shell dos batch-file

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

如何使用jQuery动画更改背景图像?

我想用慢动画改变背景图像,但它不起作用

 $('body').stop().animate({background:'url(1.jpg)'},'slow');
Run Code Online (Sandbox Code Playgroud)

语法有问题!!

jquery animation background image

18
推荐指数
1
解决办法
9万
查看次数

WPF菜单显示在窗口的左侧

我在DockPanel中有一个简单的菜单.这是XAML:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<DockPanel>
    <Menu DockPanel.Dock="Top">
        <MenuItem Name="file" Header="_File">
            <MenuItem Name="exitMenuItem" Header="E_xit"/>
        </MenuItem>
    </Menu>
    <Grid>
    </Grid>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)

为什么菜单会像大多数应用程序一样下拉到窗口边框的左侧而不是右侧?

Window的截图

wpf xaml menu

5
推荐指数
1
解决办法
2098
查看次数

从客户端检测到潜在危险的Request.Form值

我在我的MVC.NET站点上使用CKEditor/CKFinder作为wysiwyg编辑器.

我已设置[ValidateInput(false)]并在本地调试时有效,但在发布网站时收到以下错误:

A potentially dangerous Request.Form value was detected from the client (message="<p>
<em>Testing</e...").
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释为什么发布的网站不同于本地网站,特别是当我设置[ValidateInput(false)]

*更新:*我使用的是.Net 3.5,所以不应该 [ValidateInput(false)]开箱即用?

asp.net-mvc ckeditor ckfinder

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

从Linear PCM中提取音频通道

我想从LPCM原始文件中提取通道音频,即提取立体声LPCM文件的左右声道.LPCM是16位深度,交错,2个通道,litle端.从我收集的字节的顺序是{LeftChannel,RightChannel,LeftChannel,RightChannel ...},因为它是16位深度,每个通道将有2个字节的样本对吗?

所以我的问题是,如果我想提取左通道,那么我将采用0,2,4,6 ... n*2地址中的字节?而右边的通道是1,3,4,...(n*2 + 1).

在提取音频通道后,我应该将提取的通道的格式设置为16位深度,1通道?

提前致谢

这是我目前用来从AssetReader中提取PCM音频的代码.这段代码可以正常编写音乐文件而不提取其频道,所以我可能是由格式或其他东西引起的......

    NSURL *assetURL = [song valueForProperty:MPMediaItemPropertyAssetURL];
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                [NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey, 
                                [NSNumber numberWithFloat:44100.0], AVSampleRateKey,
                                [NSNumber numberWithInt:2], AVNumberOfChannelsKey,
                            //  [NSData dataWithBytes:&channelLayout length:sizeof(AudioChannelLayout)], AVChannelLayoutKey,
                                [NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
                                [NSNumber numberWithBool:NO], AVLinearPCMIsNonInterleaved,
                                [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
                                [NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey,
                                nil];
NSError *assetError = nil;
AVAssetReader *assetReader = [[AVAssetReader assetReaderWithAsset:songAsset
                                                            error:&assetError]
                              retain];
if (assetError) {
    NSLog (@"error: %@", assetError);
    return;
}

AVAssetReaderOutput *assetReaderOutput = [[AVAssetReaderAudioMixOutput 
                                           assetReaderAudioMixOutputWithAudioTracks:songAsset.tracks
                                           audioSettings: outputSettings]
                                          retain]; …
Run Code Online (Sandbox Code Playgroud)

iphone audio pcm

8
推荐指数
1
解决办法
4790
查看次数

在Package Explorer视图中筛选空目录

在eclipse中有没有办法在包浏览器视图中过滤/隐藏空目录树?

这与过滤".svn"或maven的目标或过滤空包等目录不同.它更多的是尝试清理由于过滤规则而出现的空目录树.

上下文 - 我们在工作区中有一个通用项目,它使用过滤器来忽略基于非文本的文件(mp3,jpgs等).它允许我们在eclipse中快速编辑我们的文件.问题是由于过滤器存在大量空文件夹.如果eclipse可以忽略任何由于过滤器而导致的空文件夹,那么它将使项目更清晰.

更新 - 我在eclipse的buzilla系统中为那些希望拥有此功能的人提交了一个错误报告:https://bugs.eclipse.org/bugs/show_bug.cgi?id = 334052

eclipse

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

ASP.NET MVC - [Bind(Exclude ="Id")的替代方案]

是否有[Bind(Exclude = "Id")](相关问题)的替代方案?

我能写一个模型活页夹吗?

c# modelbinders asp.net-mvc-2

19
推荐指数
4
解决办法
3万
查看次数

PDF可填写表单是否可以将自身发布到HTTPS URL?

我正在构建一个显示PDF的webapp.PDF有可填写的表格.而不是让用户保存表单,然后将其重新上传到webapp,我们的想法是调整PDF,以便当用户使用时,它可以从浏览器内部(当用户点击时)将POST本身发送到某个HTTPS端点.完成.

这可行吗?如果是这样,怎么样?如果没有,有什么建议吗?谢谢.

pdf post pdf-form

8
推荐指数
1
解决办法
7943
查看次数

如何逐步绘制矢量路径?(Raphael.js)

如何为矢量路径设置动画,就像它正在逐渐被绘制一样?换句话说,逐个像素地慢慢显示路径.

我正在使用Raphaël.js,但是如果你的答案不是特定于库的 - 也许有一些通用的编程模式来做这种事情(我对矢量动画很新) - 欢迎!


使用直线路径很容易,就像该页面上的示例一样简单::

path("M114 253").animate({path: "M114 253 L 234 253"});
Run Code Online (Sandbox Code Playgroud)

但尝试改变该页面上的代码,比如说,这样::

path("M114 26").animate({path: "M114 26 C 24 23 234 253 234 253"});
Run Code Online (Sandbox Code Playgroud)

你会明白我的意思.从初始状态(点"M114 26")到结束状态(曲线"C 24 23 234 253 234 253",从点"M114 26"开始),路径肯定是动画的,但不是以有问题的方式指定,不是像它正在被吸引.

我不知道怎么animateAlong能这样做.它可以沿着路径为对象设置动画,但是如何在对象沿着它进行动画处理时使这条路径逐渐显示出来?


解决方案?

(通过peteorpeter的回答.)

似乎目前最好的方法是使用原始SVG通过'假'破折号.有关说明,请参阅本演示本文档,第4页.

如何制作渐进式绘图?

我们必须使用stroke-dasharraystroke-dashoffset知道要绘制的曲线长度.此代码在屏幕上不显示圆形,椭圆形,折线,多边形或路径:

<[element] style="stroke-dasharray:[curve_length],[curve_length]; stroke-dashoffset:[curve_length]"/>
Run Code Online (Sandbox Code Playgroud)

如果在animate元素stroke-dashoffset减少到0,我们将逐步绘制曲线.

<circle cx="200" cy="200" r="115"
    style="fill:none; stroke:blue; stroke-dasharray:723,723; stroke-dashoffset:723">
    <animate begin="0" attributeName="stroke-dashoffset"
        from="723" to="0" dur="5s" fill="freeze"/>
</circle> …
Run Code Online (Sandbox Code Playgroud)

javascript animation svg bezier vector

31
推荐指数
5
解决办法
4万
查看次数