Skip to content

Commit

Permalink
Delegating constructor with move semantics and std::forward
Browse files Browse the repository at this point in the history
  • Loading branch information
Constellation committed Nov 28, 2013
1 parent eca2838 commit 8bd6333
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions iv/forward.h
@@ -0,0 +1,10 @@
#ifndef IV_FORWARD_H_
#define IV_FORWARD_H_
#include <utility>

#define IV_FORWARD_CONSTRUCTOR(Derived, Base) \
template<class... Args> \
Derived(Args&&... args) \
: Base(std::forward<Args>(args)...) { }

#endif // IV_FORWARD_H_
3 changes: 2 additions & 1 deletion iv/lv5/jsarray_iterator.h
@@ -1,5 +1,6 @@
#ifndef IV_LV5_JSARRAY_ITERATOR_H_
#define IV_LV5_JSARRAY_ITERATOR_H_
#include <iv/forward.h>
#include <iv/lv5/error_check.h>
#include <iv/lv5/property.h>
#include <iv/lv5/jsval.h>
Expand Down Expand Up @@ -56,7 +57,7 @@ class JSArrayIterator : public JSArrayIteratorSuper {
return reinterpret_cast<uintptr_t>(kUniqueSymbol);
}

using JSArrayIteratorSuper::JSArrayIteratorSuper;
IV_FORWARD_CONSTRUCTOR(JSArrayIterator, JSArrayIteratorSuper)
};

} } // namespace iv::lv5
Expand Down
3 changes: 2 additions & 1 deletion iv/lv5/jsmap_iterator.h
@@ -1,5 +1,6 @@
#ifndef IV_LV5_JSMAP_ITERATOR_H_
#define IV_LV5_JSMAP_ITERATOR_H_
#include <iv/forward.h>
#include <iv/lv5/error_check.h>
#include <iv/lv5/property.h>
#include <iv/lv5/jsval.h>
Expand Down Expand Up @@ -55,7 +56,7 @@ class JSMapIterator : public JSMapIteratorSuper {
return reinterpret_cast<uintptr_t>(kUniqueSymbol);
}

using JSMapIteratorSuper::JSMapIteratorSuper;
IV_FORWARD_CONSTRUCTOR(JSMapIterator, JSMapIteratorSuper)
};

} } // namespace iv::lv5
Expand Down
3 changes: 2 additions & 1 deletion iv/lv5/jsstring_iterator.h
@@ -1,5 +1,6 @@
#ifndef IV_LV5_JSSTRING_ITERATOR_H_
#define IV_LV5_JSSTRING_ITERATOR_H_
#include <iv/forward.h>
#include <iv/lv5/error_check.h>
#include <iv/lv5/property.h>
#include <iv/lv5/jsval.h>
Expand Down Expand Up @@ -44,7 +45,7 @@ class JSStringIterator : public JSStringIteratorSuper {
return reinterpret_cast<uintptr_t>(kUniqueSymbol);
}

using JSStringIteratorSuper::JSStringIteratorSuper;
IV_FORWARD_CONSTRUCTOR(JSStringIterator, JSStringIteratorSuper)
};

} } // namespace iv::lv5
Expand Down

0 comments on commit 8bd6333

Please sign in to comment.