小编Mus*_*shy的帖子

std :: unique_ptr的推荐用法

a的std::unique_ptr具体用途是什么,何时以及如何最好地使用?

我发现:

关于unique_ptr表演

我已经知道了:

  1. std::unique_ptr 是用C++ 11开发的替代品 std::auto_ptr
  2. a std::unique_ptr没有引用计数和它所指向的"拥有"对象
  3. a没有复制/分配 std::unique_ptr
  4. 当我需要一个独特的指针时,std::unique_ptr就是结构

我想知道的是:

  1. 是否使用了std::unique_ptr更好的(除了唯一性)别的
    东西?在这种情况下我会得到什么?
  2. 如果是这样,在什么情况下何时?
  3. 鉴于需要移动语义,这会不会有std::unique_ptr利于
    整体?
  4. 如果std::shared_ptr在几乎所有情况下都能满足动态内存管理的需要,为什么我可以处理一std::unique_ptr件事(同样,
    除了唯一性)?

c++ smart-pointers unique-ptr c++11

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

PLS-00201 - 必须声明标识符

我执行了一个创建下表的PL/SQL脚本

TABLE_NAME VARCHAR2(30) := 'B2BOWNER.SSC_Page_Map';
Run Code Online (Sandbox Code Playgroud)

我使用参数为这个表创建了一个insert函数

CREATE OR REPLACE FUNCTION F_SSC_Page_Map_Insert(
         p_page_id   IN B2BOWNER.SSC_Page_Map.Page_ID_NBR%TYPE, 
         p_page_type IN B2BOWNER.SSC_Page_Map.Page_Type%TYPE, 
         p_page_dcpn IN B2BOWNER.SSC_Page_Map.Page_Dcpn%TYPE)
Run Code Online (Sandbox Code Playgroud)

我被通知我必须B2BOWNER.SSC_Page_Map在它出现作为我的函数的参数之前声明.为什么我收到此错误?

编辑:实际错误

Warning: compiled but with compilation errors
Errors for FUNCTION F_SSC_PAGE_MAP_INSERT

LINE/COL ERROR                                                            
-------- -----------------------------------------------------------------
2/48     PLS-00201: identifier 'SSC_PAGE_MAP.PAGE_ID_NBR' must be declared
0/0      PL/SQL: Compilation unit analysis terminated 
Run Code Online (Sandbox Code Playgroud)

编辑:完整的PL/SQL函数

RETURN INTEGER
IS
   TABLE_DOES_NOT_EXIST exception;  
   PRAGMA EXCEPTION_INIT(TABLE_DOES_NOT_EXIST, -942); -- ORA-00942

BEGIN

   INSERT INTO 
       B2BOWNER.SSC_Page_Map VALUES(
           p_page_id, 
           p_page_type, 
           p_page_dcpn);

   RETURN 0;

   EXCEPTION
       WHEN TABLE_DOES_NOT_EXIST THEN
           RETURN -1; …
Run Code Online (Sandbox Code Playgroud)

oracle plsql function

24
推荐指数
2
解决办法
20万
查看次数

将ByteArrayInputStream的内容转换为String

我读过这篇文章,但我没有关注.我已经看过这个,但还没有看到一个将a转换ByteArrayInputStreamString使用a 的正确例子ByteArrayOutputStream.

要检索的内容ByteArrayInputStreamString,使用ByteArrayOutputstream推荐的还是有一个更可取的方法?

我正在考虑这个例子并扩展ByteArrayInputStream和利用一个Decorator来增加运行时的功能.任何对此的兴趣都是采用ByteArrayOutputStream?的更好解决方案?

java string bytearrayoutputstream bytearrayinputstream

22
推荐指数
3
解决办法
6万
查看次数

提高::变体; std :: unique_ptr和copy

此问题确定不可复制的类型不能与Boost变体一起使用

Tree

template <class T = int>

class Tree{

private:

         class TreeNode{

         public:
                 std::unique_ptr Nodes
                 Move constructors and move assignment + other public members

         private:

                 TreeNode(const TreeNode &other);      (= delete not supported on compiler)
                 TreeNode& operator=(const TreeNode &rhs);    (= delete not supported on compiler)


         };  // End Tree Node Class Definition


         Tree(const Tree &other);     (= delete not supported on compiler)
         Tree& operator=(const Tree &rhs);    (= delete not supported on compiler)

public:

         Move constructors and move assignment + other public …
Run Code Online (Sandbox Code Playgroud)

c++ unique-ptr boost-variant c++11

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

单例模式和std :: unique_ptr

std::unique_ptr唯一地控制它指向的对象,因此不利用引用计数.单例确保只能使用引用计数创建一个对象.

那么std::unique_ptr与单身人士的表现相同吗?

c++ singleton unique-ptr

6
推荐指数
3
解决办法
5191
查看次数

std::cin:: 以及为什么保留换行符

参考为什么在我包含 cin.get() 后控制台会关闭?

我正在利用 std::cin.get()

#include<iostream>    

char decision = ' ';
bool wrong = true;

while (wrong) {
    std::cout << "\n(I)nteractive or (B)atch Session?: ";

    if(std::cin) {
        decision = std::cin.get();

        if(std::cin.eof())
            throw CustomException("Error occurred while reading input\n");
    } else {
        throw CustomException("Error occurred while reading input\n");
    }

   decision = std::tolower(decision);
   if (decision != 'i' && decision != 'b')
        std::cout << "\nPlease enter an 'I' or 'B'\n";
   else
        wrong = false;
}
Run Code Online (Sandbox Code Playgroud)

我读了basic_istream::sentrystd::cin::get

我选择使用std::getlinewhile …

c++ newline cin

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

Java JPanel getGraphics()

由于Java只支持single inheritance,我希望paint直接在一个JPanel类的成员的实例上Panel.我抓住了Graphics会员的一个实例,然后把我想要的任何东西都涂在上面.

如果不重写,我怎么能不继承JComponentJPanel仍然利用getGraphics()绘画?thispublic void paintComponent(Graphics g)

private class Panel
{
      private JPanel panel;
      private Grahics g;

      public Panel()
      {
           panel = new JPanel();
      }

      public void draw()
      {
           g = panel.getGraphics();
           g.setColor(Color.CYAN);
           g.draw(Some Component);
           panel.repaint();
      }
}
Run Code Online (Sandbox Code Playgroud)

面板被添加到JFrame在调用之前可见的面板中panel.draw().这种方法对我不起作用,虽然我已经知道如何通过继承JPanel和覆盖来绘制自定义组件,但我public void paintComponent(Graphics g)不想继承JPanel.

java graphics swing jpanel paintcomponent

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

运行运行其他脚本文件的SQL*Plus脚本

好的,所以我读了这个,但我不认为答案与问题相符.我相信OP正在询问如何创建运行其他SQL Plus脚本的SQL Plus脚本,但所选答案揭示了如何在SQL*Plus中运行SQL脚本.

我想知道如何创建一个SQL Plus脚本,该脚本在运行时会在同一目录中执行其他SQL Plus脚本.

oracle plsql sqlplus

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

JSP链接到控制器映射,返回映射到jsp文件,但浏览器没有显示任何内容

我有一个链接

<a href="<c:url value="localhost:8080/CustomerRelationshipManagement/configureUpdate?
                            firstName=${temp.firstName}&lastName=${temp.lastName}&email=${temp.email}"/>">Update</a>
Run Code Online (Sandbox Code Playgroud)

指向弹簧mvc映射

@RequestMapping(value="configureUpdate", method = RequestMethod.GET)
public String configureUpdate(@RequestParam("firstName") String firstName, 
        @RequestParam("lastName") String lastName,  @RequestParam("email") String email, 
        Model model)
{

    Customer customer = new Customer(firstName, lastName, email);

    model.addAttribute("customer", customer);

    return "update-customer";
}
Run Code Online (Sandbox Code Playgroud)

因此,eclipse中的浏览器就会显示出来

网页无法显示

我试图解决这个问题,但是在处理完成后没有发现浏览器继续下一个JSP页面的任何方法.

jsp jstl

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

Pl/SQL过程CURSOR For循环

我是PL/SQL新手并尝试使用CURSOR.我想验证一个插入过程,所以我写了另一个程序来这样做.

CREATE OR REPLACE PROCEDURE verify_insert

IS

   CURSOR map_cur IS

      SELECT Page_ID_NBR, Page_Type, Page_Dcpn FROM SSC_Page_Map;

      map_rec map_cur%ROWTYPE;

BEGIN

   OPEN map_cur;

   FOR map_rec in map_cur

   LOOP

      DBMS_OUTPUT.PUT_LINE('ID: ' || map_cur.Page_ID_NBR || ' ' || 'Type' ||  map_cur.Page_Type || ' ' || 'Description' || map_cur.Page_Dcpn);   

   END LOOP;

   CLOSE map_cur;

END;

SHOW ERRORS PROCEDURE verify_insert;
Run Code Online (Sandbox Code Playgroud)

我收到以下消息

[Warning] ORA-24344: success with compilation error
19/44   PLS-00225: subprogram or cursor 'MAP_CUR' reference is out of scope
19/5    PL/SQL: Statement ignored
(47: 0): Warning: compiled but …
Run Code Online (Sandbox Code Playgroud)

toad plsql oracle11g

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