-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
509 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
#include <dingo/container.h> | ||
#include <dingo/storage/external.h> | ||
#include <dingo/storage/unique.h> | ||
// | ||
// This file is part of dingo project <https://github.com/romanpauk/dingo> | ||
// | ||
// See LICENSE for license and copyright information | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
#include <dingo/container.h> | ||
#include <dingo/storage/external.h> | ||
#include <dingo/storage/unique.h> | ||
|
||
//// | ||
struct A { | ||
A(int); // Definition is not required as constructor is not called | ||
A(double, double) {} // Definition is required as constructor is called | ||
A(int); // Definition is not required as constructor is not called | ||
A(double) {} // Definition is required as constructor is called | ||
}; | ||
|
||
//// | ||
|
||
int main() { | ||
using namespace dingo; | ||
//// | ||
container<> container; | ||
container.register_type<scope<external>, storage<double>>(1.1); | ||
|
||
// Constructor with a highest arity will be used (factory<> is deduced | ||
// automatically) | ||
container.register_type<scope<unique>, | ||
storage<A> /*, factory<constructor<A>> */>(); | ||
// Register class A that will be constructed using manually selected | ||
// A(double) constructor. Manually disambiguation is required to avoid | ||
// compile time assertion | ||
container.register_type<scope<unique>, storage<A>, | ||
factory<constructor<A(double)>>>(); | ||
//// | ||
} |
21 changes: 10 additions & 11 deletions
21
examples/factory_constructor_concrete.cpp → examples/factory_constructor_deduction.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
#include <dingo/container.h> | ||
#include <dingo/storage/external.h> | ||
#include <dingo/storage/unique.h> | ||
// | ||
// This file is part of dingo project <https://github.com/romanpauk/dingo> | ||
// | ||
// See LICENSE for license and copyright information | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
#include <dingo/container.h> | ||
#include <dingo/storage/external.h> | ||
#include <dingo/storage/unique.h> | ||
|
||
//// | ||
struct A { | ||
A(int); // Definition is not required as constructor is not called | ||
A(double) {} // Definition is required as constructor is called | ||
A(int); // Definition is not required as constructor is not called | ||
A(double, double) {} // Definition is required as constructor is called | ||
}; | ||
|
||
//// | ||
|
||
int main() { | ||
using namespace dingo; | ||
//// | ||
container<> container; | ||
container.register_type<scope<external>, storage<double>>(1.1); | ||
|
||
// Register class A that will be constructed using manually selected | ||
// A(double) constructor. Manually disambiguation is required to avoid | ||
// compile time assertion | ||
container.register_type<scope<unique>, storage<A>, | ||
factory<constructor<A(double)>>>(); | ||
// Constructor with a highest arity will be used (factory<> is deduced | ||
// automatically) | ||
container.register_type<scope<unique>, | ||
storage<A> /*, factory<constructor_deduction<A>> */>(); | ||
//// | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.