-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdaw_poly_var_test.cpp
More file actions
50 lines (43 loc) · 1.06 KB
/
Copy pathdaw_poly_var_test.cpp
File metadata and controls
50 lines (43 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) Darrell Wright
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/beached/header_libraries
//
#include "daw/daw_benchmark.h"
#include "daw/daw_poly_var.h"
#include <iostream>
namespace {
struct Base {
Base( ) = default;
virtual ~Base( ) = default;
Base( Base const & ) = default;
Base( Base && ) = default;
Base &operator=( Base const & ) = default;
[[maybe_unused]] Base &operator=( Base && ) = default;
virtual int get_num( ) = 0;
};
struct C1 : Base {
C1( ) = default;
int get_num( ) override {
return 1;
}
};
struct C2 : Base {
C2( ) = default;
int get_num( ) override {
return 2;
}
};
} // namespace
int main( int argc, char ** ) {
if( argc % 2 == 0 ) {
daw::poly_var<Base, C1, C2> val( C2{ } );
std::cout << "result: " << val->get_num( ) << '\n';
return 0;
}
daw::poly_var<Base, C1, C2> val( C1{ } );
std::cout << "result: " << val->get_num( ) << '\n';
return 0;
}