teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

fix code

2015/10/08 15:07

投稿

yohhoy
yohhoy

スコア6191

answer CHANGED
@@ -13,7 +13,7 @@
13
13
  { callback_(); }
14
14
 
15
15
  private:
16
- std::function<void()> callback_ = []{}
16
+ std::function<void()> callback_ = []{};
17
17
  };
18
18
  ```
19
19
  [http://melpon.org/wandbox/permlink/Yz041bVYUteFs8P0](http://melpon.org/wandbox/permlink/Yz041bVYUteFs8P0)

1

よりC++11/14風に

2015/10/08 15:07

投稿

yohhoy
yohhoy

スコア6191

answer CHANGED
@@ -4,17 +4,16 @@
4
4
 
5
5
  class some_class {
6
6
  public:
7
- some_class()
7
+ some_class() = default;
8
- : callback_([]{}) {}
9
8
 
10
9
  explicit some_class(std::function<void()> f)
11
10
  : callback_(std::move(f)) {}
12
11
 
13
- ~some_class()
12
+ ~some_class() noexcept(false)
14
13
  { callback_(); }
15
14
 
16
15
  private:
17
- std::function<void()> callback_;
16
+ std::function<void()> callback_ = []{}
18
17
  };
19
18
  ```
20
19
  [http://melpon.org/wandbox/permlink/Yz041bVYUteFs8P0](http://melpon.org/wandbox/permlink/Yz041bVYUteFs8P0)