Skip to content

Commit 4bc3730

Browse files
authored
Merge pull request #468 from mikomikotaishi/patch-1
Replace inline namespace with implicitly imported namespace
2 parents ab7daaa + 183b01a commit 4bc3730

4 files changed

Lines changed: 14 additions & 22 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RtAudio is a set of C++ classes that provides a common API (Application Programm
2828

2929
RtAudio incorporates the concept of audio streams, which represent audio output (playback) and/or input (recording). Available audio devices and their capabilities can be enumerated and then specified when opening a stream. Where applicable, multiple API support can be compiled and a particular API specified when creating an RtAudio instance. See the \ref apinotes section for information specific to each of the supported audio APIs.
3030

31-
RtAudio is also offered as a module, which is enabled with `RTAUDIO_BUILD_MODULES`, and is accessed with `import rt.audio;`. Namespaces are inlined, so classes can be accessed through namespace `rt::audio` or through the global namespace (for example, `rt::audio::RtApi` and `::RtApi` are both valid).
31+
RtAudio is also offered as a module, which is enabled with `RTAUDIO_BUILD_MODULES`, and is accessed with `import rt.audio;`. Namespaces are implicitly imported (unless disabled with `RTAUDIO_USE_NAMESPACE`), so classes can be accessed through namespace `rt::audio` or through the global namespace (for example, `rt::audio::RtApi` and `::RtApi` are both valid).
3232

3333
## Building
3434

RtAudio.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#include <windows.h>
5656
#endif
5757

58+
using namespace rt::audio;
59+
5860
// Static variable definitions.
5961
const unsigned int RtApi::MAX_SAMPLE_RATES = 14;
6062
const unsigned int RtApi::SAMPLE_RATES[] = {

RtAudio.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@
8585
#include <functional>
8686
#include <memory>
8787

88-
inline namespace rt {
89-
inline namespace audio {
88+
namespace rt::audio {
9089

9190
/*! \typedef typedef unsigned long RtAudioFormat;
9291
\brief RtAudio data format type.
@@ -651,7 +650,6 @@ class RTAUDIO_DLL_PUBLIC RtAudio
651650
std::shared_ptr<RtApi> rtapi_;
652651
};
653652

654-
}
655653
}
656654

657655
// Operating system dependent thread functionality.
@@ -676,12 +674,10 @@ inline namespace audio {
676674
// Using pthread library for various flavors of unix.
677675
#include <pthread.h>
678676

679-
inline namespace rt {
680-
inline namespace audio {
677+
namespace rt::audio {
681678
typedef pthread_t ThreadHandle;
682679
typedef pthread_mutex_t StreamMutex;
683680
}
684-
}
685681

686682
#endif
687683

@@ -694,8 +690,7 @@ inline namespace audio {
694690

695691
#endif
696692

697-
inline namespace rt {
698-
inline namespace audio {
693+
namespace rt::audio {
699694

700695
// This global structure type is used to pass callback information
701696
// between the private RtAudio stream structure and global callback
@@ -755,7 +750,6 @@ class S24 {
755750
};
756751
#pragma pack(pop)
757752

758-
}
759753
}
760754

761755
#if defined( HAVE_GETTIMEOFDAY )
@@ -764,8 +758,7 @@ class S24 {
764758

765759
#include <sstream>
766760

767-
inline namespace rt {
768-
inline namespace audio {
761+
namespace rt::audio {
769762

770763
class RTAUDIO_DLL_PUBLIC RtApi
771764
{
@@ -952,11 +945,13 @@ inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTi
952945
inline void RtAudio :: setErrorCallback( RtAudioErrorCallback errorCallback ) { rtapi_->setErrorCallback( errorCallback ); }
953946
inline void RtAudio :: showWarnings( bool value ) { rtapi_->showWarnings( value ); }
954947

955-
}
956948
}
957949

958950
#endif
959951

952+
#ifndef RTAUDIO_USE_NAMESPACE
953+
using namespace rt::audio;
954+
#endif
960955

961956
// Indentation settings for Vim and Emacs
962957
//

modules/RtAudio.cppm

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ module;
44

55
export module rt.audio;
66

7-
export
8-
#ifdef RTAUDIO_USE_NAMESPACE
9-
inline namespace rt {
10-
inline namespace audio {
11-
#else
12-
namespace rt::audio {
13-
#endif
7+
export namespace rt::audio {
148
using rt::audio::RtAudioFormat;
159
using rt::audio::RtAudioStreamFlags;
1610
using rt::audio::RtAudioStreamStatus;
@@ -24,6 +18,7 @@ namespace rt::audio {
2418
using rt::audio::CallbackInfo;
2519
using rt::audio::S24;
2620
}
27-
#ifdef RTAUDIO_USE_NAMESPACE
28-
}
21+
22+
#ifndef RTAUDIO_USE_NAMESPACE
23+
using namespace rt::audio;
2924
#endif

0 commit comments

Comments
 (0)