Skip to content

Commit

Permalink
Instantiating from FullNamespaceModule means instantiating from its i…
Browse files Browse the repository at this point in the history
…mportedFrom module.

Also enable std::cout usage in complex.d, after initializing it by calling std::ios_base::Init::Init() in non-MSVC environments.
  • Loading branch information
Syniurge committed Oct 29, 2019
1 parent 686b19f commit 918ec4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions dmd/cpp/cppmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class DeclMapper
::Module *minst, *importedFrom;
DeclMapper(::Module *minst, ::Module *importedFrom) : minst(minst), importedFrom(importedFrom) {}
DeclMapper(Dsymbol* s) : DeclMapper(s->getInstantiatingModule(), s->getModule()->importedFrom) {}
DeclMapper(FullNamespaceModule* nsMod) : DeclMapper(nsMod->importedFrom, nsMod->importedFrom) {}

/*
* Declarations
Expand Down
11 changes: 6 additions & 5 deletions tests/calypso/libstdc++/complex.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ pragma (cppmap, "<iostream>");
pragma (cppmap, "<iomanip>");

import std.stdio;
import (C++) std.complex;
import (C++) std._ : cout, fixed, setprecision, pow, acos, exp;
import (C++) std;

void main()
{
// cout << /+fixed(cout) << +/setprecision(1);
version (CppRuntime_Microsoft) {} else ios_base.Init(); // initialize std::cout

cout << /+fixed(cout) << +/setprecision(1);

auto i1 = complex!double(0.0, 1.0);
auto z1 = i1;
z1 *= i1;
// cout << "i * i = " << z1 << '\n';
cout << "i * i = " << z1 << '\n';

complex!float z2 = pow(i1, 2);
// cout << "pow(i, 2) = " << z2 << '\n';
cout << "pow(i, 2) = " << z2 << '\n';

double PI = acos(-1);
// complex!double z3 = exp(1i * PI);
Expand Down

0 comments on commit 918ec4a

Please sign in to comment.