小编Mic*_*ele的帖子

如何从vector向量pop_back共享指针并转换为unique_ptr

我正在尝试从我的vector中弹出我的shared_pointer并转换为unique_ptr.不幸的是,它给出了一个奇怪的编译信息.

IFCCB.cpp:

std::unique_ptr<IFC> IFCCCB::getElementVectorIFC()
{
    return (std::unique_ptr<IFC>(make_unique<IFC>(m_shpVectorIFC.pop_back())));
}
Run Code Online (Sandbox Code Playgroud)

IFCCB.h:

public:
unique_ptr<IFC> getElementVectorIFC();
Run Code Online (Sandbox Code Playgroud)

编译错误:

错误C2784:'enable_if :: value,std :: unique_ptr <_Ty,std :: default_delete <_Ty >>> :: type std :: make_unique(_Types && ...)':无法推断'_Types &&的模板参数'from'void'

据我所知,我正在做我在别处看到的事情.

我查看了make_unique信息,但它没有给出一个非常好的示例,并且使用了unique_ptr.有任何想法吗?

c++ vector shared-ptr unique-ptr

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

psobject 属性集失去顺序 - 如何保留顺序?

我正在使用 Export-Excel,并且我正在使用的 psobject 属性集正在重新排序,这使得我的 Excel 标题顺序错误。

这是我的代码:

       foreach ($errCode in $ErrCodes) 
       {
          $resultHelp = [System.Collections.Generic.List[psobject]]::new() 
          Write-Host "another:"
          $err = $errCode #get each error code to lookup in mdb file
          Write-Host $err
          $resultHelp = ProcessHelpMDB -mdbLookupError $errCode -mdbFilePath $basePathFull -mdbDeviceSeries $Ver #######

          $result = [ordered] @{
                  "ScreenNumber" = ""
                  "KKey" = ""
                  "EnglishUS" = ""
                  "PictureID" = ""
                  "ImageFound" =""
                  "ImageFileName" = ""
          } #this didn't do anything
          #loop thru results from Help MDB file for $errCode
          ###this loses order:
          $result …
Run Code Online (Sandbox Code Playgroud)

powershell ordereddictionary export-to-excel

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

使用凭据在其他服务器上获取子项目

我正在编写一个在其他服务器上使用 get-childitem 的脚本,但需要更改它,以便它使用其他服务器上的本地帐户的凭据来执行此操作。当我只是使用 Active Directory 来执行此操作时,我使用 AD 登录名将任务保存在调度程序中,并且使用 UNC 路径在另一台服务器上效果很好。但我们最近决定将其更改为本地登录,我收到一条错误消息,试图使用网络使用。有谁知道使用 UNC 路径执行此操作的好方法吗?或者,知道为什么以下给出错误消息吗?

function GetSecureLogin(){
   $global:username = "stuff"
   $global:password = get-content C:\filename.txt | convertto-securestring
}

function Cleanup([string]$Drive) {
   try {
      $deleteTime = -42
      $now = Get-Date
      **#this is saying cannot find path '\\name.na.xxx.net\20xServerBackup\V' name truncated**
      Get-ChildItem -Path $Drive -Recurse -Force |Where-Object {$_.LastWriteTime -lt $limit} | Remove-Item -Force 
   }
   Catch{
      Write-Host "Failed"
   }
}

#####################start of script####################
$share = '\\name.na.xxx.net\20xServerBackup\'
$TheDrive = '\\name.na.xxx.net\20xServerBackup\VMs\'

$global:password = ""
$global:username = ""
GetSecureLogin

net use …
Run Code Online (Sandbox Code Playgroud)

credentials unc get-childitem powershell-3.0

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

将帖子数据转换为字符串

我正在编写一个php程序,它将用户输入转换为字符串,并计算每个字符的使用次数,最终计算每个单词.有谁知道如何将帖子数据转换为字符串?我正在研究implodecount_chars,但内爆并没有像预期的那样转换为字符串.我不确定如何显示它遇到的错误以提供更多信息.我正在运行它并在phpFiddle中编写它.我不知道如何在其他地方运行它.请提供有关implode可能出错的信息,如何在phpFiddle中显示错误,或在没有phpFiddle的浏览器中运行此信息.

<?php
     echo $_POST['value'];
     $post_string = implode($_POST);
     foreach (count_chars($post_string, 1) as $i => $val) {
         echo "there were $val instances of \"", chr($i) , "\" in the string. \n";
     }
?>
<form method="post" action="">
<input type="text" name="value">
<input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)

php

0
推荐指数
2
解决办法
9052
查看次数

如何获得size_of $ _GET

我想获得通过$ _GET提交的值的数量.我将使用for循环,每7个将被保存到一个类.有谁知道如何找到$ _GET数组的Size_of?我查看了这个信息$ _GET手册,但看不到我在找什么.

这是我在提交后去的课程中开始的代码片段.

for($i=0;$i<$_GET<size>;$i++) {
    $ID = $_GET["ID"][$i];
    $Desc = $_GET["Desc"][$i];
    $Yevaluation = $_GET["Yevaluation"][$i];
    $Mevaluation = $_GET["Mevaluation"][$i];
    $Cevaluation = $_GET["Cevaluation"][$i];
    $Kevaluation = $_GET["Kevaluation"][$i];
    $comment = $_GET["comment"][$i];
    //saving bunch to class next
}
Run Code Online (Sandbox Code Playgroud)

php arrays for-loop get superglobals

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