@@ -26,17 +26,16 @@ class ClassDescription : public Description {
2626 std::string type;
2727
2828 public:
29- const bool has_subject = true ;
3029 T subject; // subject field public for usage in `expect([self.]subject)`
3130
3231 // Constructor
3332 // if there's no explicit subject given, then use
3433 // the default constructor of the given type as the implicit subject.
3534 ClassDescription (Block block, std::source_location location = std::source_location::current())
36- : block(block), type( " : " + Util::demangle( typeid (T).name())), subject(T()) {
37- this -> description = Pretty::to_word (subject);
38- this -> set_location (location);
39- }
35+ : Description(location, Pretty::to_word( subject)),
36+ block (block),
37+ type( " : " + Util::demangle( typeid (T).name())),
38+ subject(T()) { }
4039
4140 ClassDescription (const char * description,
4241 Block block,
@@ -67,7 +66,7 @@ class ClassDescription : public Description {
6766 : Description(location, Pretty::to_word(subject)),
6867 block(block),
6968 type(" : " + Util::demangle(typeid (T).name())),
70- subject(std::move (subject)) {}
69+ subject(std::forward<U> (subject)) {}
7170
7271 template <typename U>
7372 ClassDescription (std::initializer_list<U> init_list,
@@ -85,7 +84,7 @@ class ClassDescription : public Description {
8584 std::source_location location = std::source_location::current())
8685 : Description(location, description), block(block), subject(T(init_list)) {}
8786
88- ItCD<T>& it (const char * description ,
87+ ItCD<T>& it (const char * name ,
8988 std::function<void (ItCD<T>&)> block,
9089 std::source_location location = std::source_location::current());
9190 ItCD<T>& it (std::function<void (ItCD<T>&)> block, std::source_location location = std::source_location::current());
@@ -114,7 +113,7 @@ class ClassDescription : public Description {
114113
115114 template <class U , class B >
116115 ClassDescription<U>& context (U&& subject, B block, std::source_location location = std::source_location::current()) {
117- return this ->context (" " , subject, block, location);
116+ return this ->context (" " , std::forward<U>( subject) , block, location);
118117 }
119118 void run () override ;
120119
@@ -149,7 +148,7 @@ ClassContext<U>& ClassDescription<T>::context(const char* description,
149148 U&& subject,
150149 B block,
151150 std::source_location location) {
152- auto * context = this ->make_child <ClassContext<U>>(description, subject, block, location);
151+ auto * context = this ->make_child <ClassContext<U>>(description, std::forward<U>( subject) , block, location);
153152 context->ClassContext <U>::before_eaches = this ->before_eaches ;
154153 context->ClassContext <U>::after_eaches = this ->after_eaches ;
155154 context->timed_run ();
@@ -186,7 +185,7 @@ ClassContext<T>& Description::context(const char* description, T& subject, B blo
186185
187186template <Util::not_c_string T, class B >
188187ClassContext<T>& Description::context (T&& subject, B block, std::source_location location) {
189- auto * context = this ->make_child <ClassContext<T>>(subject, block, location);
188+ auto * context = this ->make_child <ClassContext<T>>(std::forward<T>( subject) , block, location);
190189 context->before_eaches = this ->before_eaches ;
191190 context->after_eaches = this ->after_eaches ;
192191 context->timed_run ();
@@ -195,7 +194,7 @@ ClassContext<T>& Description::context(T&& subject, B block, std::source_location
195194
196195template <class T , class B >
197196ClassContext<T>& Description::context (const char * description, T&& subject, B block, std::source_location location) {
198- auto * context = this ->make_child <ClassContext<T>>(description, subject, block, location);
197+ auto * context = this ->make_child <ClassContext<T>>(description, std::forward<T>( subject) , block, location);
199198 context->before_eaches = this ->before_eaches ;
200199 context->after_eaches = this ->after_eaches ;
201200 context->timed_run ();
0 commit comments