小编xsa*_*ami的帖子

错误:'list'不是'std'的成员而且error:template参数2无效

我正在尝试编译我的头文件,但是我遇到了我无法弄清楚的错误.

我想创建一个包含3个地图的结构:-map从单个单词到count -map从单词对到count -map从单个单词到下面单词列表

我的头文件中的代码:

#include <cstdlib>
#include <iostream>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <algorithm>
#include <map>

typedef struct {

    std::map<std::string, int> firstCounts;
    std::map<std::string, int> pairCounts;
    std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list. 

} LanguageModel;
Run Code Online (Sandbox Code Playgroud)

我得到的错误:

>   LangModel.h:24:23: error: ‘list’ is not a member of ‘std’
>      std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list. 
>                            ^
>     LangModel.h:24:23: …
Run Code Online (Sandbox Code Playgroud)

c++ dictionary list std c++11

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

在web.config IIS中的PHP(或其他)CGI配置

我最近使用Wix工具集开发了一个Web应用程序的安装程序(是的,带有安装程序的Web应用程序).

该向导将指导用户获取站点安装所需的所有基本信息,如下所示:

在此输入图像描述

在安装结束时使用自定义操作,我使用文档动态配置IIS处理CGI ,将FastCGI配置为托管PHP,Python,应用程序.有很多步骤和开发来实现这个结果,但问题在于:

我安装了应用程序,一切正常,但是,如果我卸载或安装另一个实例或其他WebApplication,IIS配置的处理程序就像全局一样,并始终指向第一个安装.(卸载应用程序时出现问题)位于C:\ Windows\System32\inetsrv\config中的applicationHost.config是IIS的配置,其"config"类似于global.

<handlers accessPolicy="Read, Script">
            <add name="PHP-FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="E:\CIM_dev\bin\php-v5.6\php-cgi.exe" resourceType="Either" />
            <add name="CGI-exe_2" path="*.exe" verb="*" modules="CgiModule" resourceType="File" requireAccess="Execute" allowPathInfo="true" />
            <add name="TRACEVerbHandler2" path="*" verb="TRACE" modules="ProtocolSupportModule" requireAccess="None" />
            <add name="OPTIONSVerbHandler2" path="*" verb="OPTIONS" modules="ProtocolSupportModule" requireAccess="None" />
            <add name="StaticFile2" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
        </handlers>
Run Code Online (Sandbox Code Playgroud)

我的问题是,有没有办法为web.config中的每个网站进行此配置?我一直在努力尝试所有的东西而没有成功.

php iis cgi fastcgi wix

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

创建GoogleApiClient实例时出现NullPointerException

我已经开始为Android Wear创建Watch Face.我已经实现了几乎所有的东西,现在我想在脸上显示手机电池.根据我在研究后的理解,这只能通过Message或Data Layer API实现.所以我开始在他所在的地区工作,但我一开始就遇到了问题.我无法连接到Google Api客户端.

我在"穿"下有两个课程 - 一个用于手表(服务)的通用和一个由我创建的课程:

public class BatteryActivity extends Activity {

    GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks( new ConnectionCallbacks() {
            @Override
            public void onConnected(Bundle connectionHint) {
                Log.i( "", "onConnected: " + connectionHint);
                // Now you can use the Data Layer API
            }
            @Override
            public void onConnectionSuspended(int cause) {
                Log.i( "", "onConnectionSuspended: " + cause);
            }
        })
        .addOnConnectionFailedListener( new OnConnectionFailedListener() {
            @Override
            public void onConnectionFailed(ConnectionResult result) {
                Log.i( "", "onConnectionFailed: " + result);
            }
        })
                // Request …
Run Code Online (Sandbox Code Playgroud)

android

7
推荐指数
1
解决办法
3464
查看次数

通过DynamicMethod调用varargs方法

我正在尝试使用DynamicMethod调用非托管类似printf的函数.在运行时我得到一个

BadImageFormatException:找不到索引.(HRESULT异常:0x80131124)

这是运行时的限制还是我的发出代码错了?

public class Program
{
    [DllImport("msvcrt40.dll",CallingConvention = CallingConvention.Cdecl)]
    public static extern int printf(string format, __arglist);

    static void Main(string[] args) {

        var method = new DynamicMethod("printf", typeof(void), new Type[0], true);
        var il = method.GetILGenerator();

        il.Emit(OpCodes.Ldstr, " %s=%d\n");
        il.Emit(OpCodes.Ldstr, "a");
        il.Emit(OpCodes.Ldc_I4_0);
        il.EmitCall(OpCodes.Call, typeof(Program).GetMethod("printf", BindingFlags.Public | BindingFlags.Static), new Type[] { typeof(string), typeof(int) });
        il.Emit(OpCodes.Pop);
        il.Emit(OpCodes.Ret);

        var action = (Action)method.CreateDelegate(typeof(Action));
        action.Invoke();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# cil reflection.emit .net-4.0 dynamicmethod

6
推荐指数
1
解决办法
611
查看次数

Random.nextBoolean()始终返回True无关紧要种子

当我运行以下代码时,无论我在for循环中使用什么范围,代码总是打印出true十次.

public static void main(String[] args) 
{
    Random bool = new Random();

    for (int i = 0; i < 10; i++) {
        bool.setSeed(i);
        System.out.println(bool.nextBoolean());
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我对代码稍作修改并让随机生成器nextBoolean()在打印之前运行一次函数,那么当我更改for循环的范围时,我得到正常的分布truefalse输出中的chages:

public static void main(String[] args) 
{
    Random bool = new Random();

    for (int i = 0; i < 10; i++) {
        bool.setSeed(i);
        bool.nextBoolean(); //Only change
        System.out.println(bool.nextBoolean());
    }
}
Run Code Online (Sandbox Code Playgroud)

在我看来,该nextBoolean()函数总是true在第一次执行时返回,这种行为是否有任何原因?

java random loops boolean

6
推荐指数
1
解决办法
1759
查看次数

从HTML元素获取图像数据

我在这里遇到了一些问题,这些问题给了我一些我现在遇到的问题的提示,但似乎没有一个问题符合这个要求.

我目前正在使用角度模块ngCropper(https://github.com/koorgoo/ngCropper),它可以轻松处理来自文件输入的图像,但我还需要它与外部URL一起工作.为了使用外部URL,我使用了faheyyy(https://github.com/koorgoo/ngCropper/issues/3)给出的建议,但现在我正在处理CORS问题,我无法对服务器进行更改.

所以,我想在隐藏的HTML元素上加载图像并以某种方式获取数据,将其编码为Base64,然后我就可以在cropper模块上使用它而无需创建新的GET请求(这将是创建CORS问题).我也尝试创建一个读取图像源的指令(该指令插入img元素)并尝试将其放在canvas元素上,然后获取dataURL:

.directive('toBase64', function ($document) {
    return {
        restrict : 'A',
        link : function (scope, element, attr) {

          element.on('load', function () {
            getBase64Image(element);
          });

          function getBase64Image(element) {
            var theImage = new Image();
            theImage.src = element.attr("src");
            var imageWidth = theImage.width;
            var imageHeight = theImage.height;

            var canvas = element.siblings('#cropCanvas');
            canvas.width = imageWidth;
            canvas.height = imageHeight;
            var ctx = canvas.getContext("2d");
            ctx.drawImage(element, 0, 0);
            var dataURL = canvas.toDataURL("image/png");
            return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
          }
        }
    };
}); …
Run Code Online (Sandbox Code Playgroud)

javascript canvas cors angularjs

5
推荐指数
0
解决办法
1174
查看次数

MockServer:解析 JSON 时出现 IllegalArgumentException

当我尝试使用 MockServer 模拟外部 HTTP API 时,mockserver 返回java.lang.IllegalArgumentException

这是测试代码:

new MockServerClient("localhost", 1080)
    .when(request("/messages")
    .withMethod("POST")
    .withQueryStringParameters(
        param("subject", "integration-test-subject")
    )
).respond(response().withStatusCode(200));
Run Code Online (Sandbox Code Playgroud)

这是例外:

java.lang.IllegalArgumentException: Exception while parsing 
[  
   {  
      "httpRequest":{  
         "method":"POST",
         "path":"/messages",
         "queryStringParameters":{  
            "subject":[  
               "integration-test-subject"
            ]
         }
      },
      "httpResponse":{  
         "statusCode":200
      },
      "times":{  
         "remainingTimes":0,
         "unlimited":true
      },
      "timeToLive":{  
         "unlimited":true
      }
   }
] for Expectation
Run Code Online (Sandbox Code Playgroud)

这是杰克逊的例外:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.lang.String` out of FIELD_NAME token
at
[  
   Source:(String)"   {  
      "httpRequest":{  
         "method":"POST",
         "path":"/messages",
         "queryStringParameters":{  
            "subject":[  
               "integration-test-subject"
            ]
         }
      },
      "httpResponse":{  
         "statusCode":200
      },
      "times":{  
         "remainingTimes":0,
         "unlimited":true
      }, …
Run Code Online (Sandbox Code Playgroud)

jackson mockserver

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

String name [] = {}之间的区别是什么?和String [] name = {};

我写在Java的代码和我在想什么使这之间的区别:String [] whateverString whatever [],如果有人能告诉我发生了什么,这是更好地利用String [] whatever= {}或使用String whatever[]= {}或这一点,只是过时.

public class Snippet136 
{
    public static void main(String [] args) 
    {
        String names[] = {"Jhonny", "Edurardo", "Francis", "Franklin", "Freedy"};
        String [] eyes_colors = { "blue", "red", "black", "green", "black"};

        System.out.print("Names:");
        for (String name: names) {
            System.out.print( " " + name );
        }

        System.out.print("\n\nEyes colors:");
        for ( String eyes_color: eyes_colors ) {
            System.out.print( " " + eyes_color );
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java

3
推荐指数
2
解决办法
2987
查看次数

为什么C打印输出较晚?

我目前正在我的Raspberry Pi计算机上运行一段C代码.它是一个随机数发生器,从连接到GPIO数字输入18的Geiger计数器读取.它产生随机位(见代码)并以8组为单位打印位.此外,每隔30秒,它打印出当前观察到的辐射水平.代码似乎工作正常,除非辐射源被带走.随机数的生成速度较慢,但​​它似乎也会减慢其余任务的速度.在程序开头打印的消息在生成一个随机数之前不会显示.发生这种情况时,不显示任何数字,但添加了一个没有数字的换行符.即使在程序运行时,辐射水平似乎每30秒打印一次,但也会在下一个随机数上打印.为什么C以错误的顺序执行代码?

#include <wiringPi.h>//library for I/O
#include <stdlib.h>
int main(int argc, char *argv[])
{
    int lastRead;//if this is first time observing current pulse
    int pulseCount = 0;//number of total pulses from Geiger counter
    long timing[4] = {0,0,0,0};//values to compare to produce one bit
    int bits[8] = {0,0,0,0,0,0,0,0};//the newest number
    int bitCount = 0;//counts how many random bits have been made
    int i = 0;
    float startTime = 0;//start of the clock
    float currentSec = 0;
    float currentMin = 0;
    float …
Run Code Online (Sandbox Code Playgroud)

c linux raspberry-pi

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

字符串连接时Java字符串池的工作原理是什么?

注意:我不是要比较角色是否等于.因为我知道如何使用String.equals()方法.这个问题是关于字符串引用的

当我开始学习类字符串及其属性作为不变性等时,我正在学习OCA考试.根据我读到或可能理解的字符串池是在创建字符串时,Java将此对象存储在他们调用的内容中字符串池,如果创建一个具有相同值的新字符串,它将引用字符串池上的字符串,除非我们使用new关键字,因为这会创建一个新引用,即使两个字符串包含相同的值.

例如:

String a = "foo";
String b = "foo";
String c = new String("foo");
boolean ab = (a == b); // This return true
boolean ac = (a == c); // This return false
Run Code Online (Sandbox Code Playgroud)

要清楚这段代码是在第一行代码中创建String a = "foo"并将其存储在String池中,而在第二行代码中它将创建String b和引用,"foo"因为它已存在于String池中.但是第3行将创建此字符串的新引用,无论它是否已存在.这是一个关于发生了什么的图形示例: http://cdn.journaldev.com/wp-content/uploads/2012/11/String-Pool-Java1.png

问题出现在以下代码行中.当串联创建字符串时,java会做出不同的东西或简单= =比较器有另一种行为吗?

例A:

String a = "hello" + " world!";
String b = "hello world!";
boolean compare = (a == b); …
Run Code Online (Sandbox Code Playgroud)

java string object-reference string-comparison string-pool

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

mod_wsgi-express:错误:指定了无效命令

我试图运行WSGI应用程序(hello.wsgi)上localhost通过apache24mod_wsgi模块,但它显示了这一点:

cd c:/apache24/bin
mod_wsgi-express start-server hello.wsgi
Run Code Online (Sandbox Code Playgroud)
Usage: mod_wsgi-express command [params]

Commands:
    module-config
    module-location

mod_wsgi-express: error: Invalid command was specified.
Run Code Online (Sandbox Code Playgroud)

请帮我!

apache python-2.7

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

使用 CSS calc() 计算剩余高度

我需要.contentdiv 使用所有可用空间

body {
    height: 100%;
}
.nav {
    padding: 20px;
}

.content {
    height: 100%;
}

<body>
    <div class="nav">nav</div>
    <div class="content">content</div>
</body>
Run Code Online (Sandbox Code Playgroud)

由于我不知道.nav我不能使用的高度,height: calc(100%-Xpx) 还有其他方法可以.content利用页面的剩余高度吗?

谢谢

css

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

新手到javascript,使用数组

想知道为什么我需要在数组长度上加4才能反向打印整个数组?

在我添加4之前它只是使用.length属性而且它只打印出6543.

提前致谢!

function reverseArray(array) {
    var newArray =[];

     for(var i = 0; i <= array.length+4; i++) {
         newArray += array.pop(i);
      }
     return newArray;
 }
var numbers = [1,2,3,4,5,6];
console.log(reverseArray(numbers));
Run Code Online (Sandbox Code Playgroud)

javascript arrays reversing

0
推荐指数
1
解决办法
61
查看次数