Skip to content

Commit

Permalink
move variant and friends into mapbox namespace for easy integration
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed Jun 9, 2014
1 parent b31579c commit df55ab6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
10 changes: 5 additions & 5 deletions recursive_wrapper.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef UTIL_VARIANT_RECURSIVE_WRAPPER_HPP
#define UTIL_VARIANT_RECURSIVE_WRAPPER_HPP
#ifndef MAPBOX_UTIL_VARIANT_RECURSIVE_WRAPPER_HPP
#define MAPBOX_UTIL_VARIANT_RECURSIVE_WRAPPER_HPP

#include <utility>

namespace util {
namespace mapbox { namespace util {

template <typename T>
class recursive_wrapper
Expand Down Expand Up @@ -123,6 +123,6 @@ inline void swap(recursive_wrapper<T>& lhs, recursive_wrapper<T>& rhs) noexcept
lhs.swap(rhs);
}

}
}}

#endif // UTIL_VARIANT_RECURSIVE_WRAPPER_HPP
#endif // MAPBOX_UTIL_VARIANT_RECURSIVE_WRAPPER_HPP
3 changes: 3 additions & 0 deletions test/bench_variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#define TEXT "Testing various variant implementations with a longish string ........................................."
//#define BOOST_VARIANT_MINIMIZE_SIZE

using namespace mapbox;

namespace test {

template <typename V>
Expand Down
2 changes: 2 additions & 0 deletions test/binary_visitor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <boost/timer/timer.hpp>
#include "variant.hpp"

using namespace mapbox;

namespace test {

template <typename T>
Expand Down
2 changes: 2 additions & 0 deletions test/recursive_wrapper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <boost/timer/timer.hpp>
#include "variant.hpp"

using namespace mapbox;

namespace test {

struct add;
Expand Down
2 changes: 2 additions & 0 deletions test/unique_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <boost/timer/timer.hpp>
#include "variant.hpp"

using namespace mapbox;

namespace test {

struct add;
Expand Down
4 changes: 3 additions & 1 deletion test/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <ostream>
#include <memory>

using namespace mapbox;

TEST_CASE( "variant version", "[variant]" ) {
unsigned int version = VARIANT_VERSION;
REQUIRE(version == 100);
Expand Down Expand Up @@ -50,7 +52,7 @@ TEST_CASE( "variant should support built-in types", "[variant]" ) {
// FIXME: does not compile: ./variant.hpp:340:14: error: use of overloaded operator '<<' is ambiguous (with operand types 'std::__1::basic_ostream<char>' and 'const nullptr_t')
// https://github.com/mapbox/variant/issues/14
//REQUIRE(v == util::variant<value_type>(nullptr));
}
}
SECTION( "unique_ptr" ) {
typedef std::unique_ptr<std::string> value_type;
util::variant<value_type> v(value_type(new std::string("hello")));
Expand Down
2 changes: 2 additions & 0 deletions test/variant_hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <cstdint>
#include <stdexcept>

using mapbox;

struct check : util::static_visitor<>
{
template <typename T>
Expand Down
12 changes: 5 additions & 7 deletions variant.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef UTIL_VARIANT_HPP
#define UTIL_VARIANT_HPP
#ifndef MAPBOX_UTIL_VARIANT_HPP
#define MAPBOX_UTIL_VARIANT_HPP

#include <utility>
#include <typeinfo>
Expand Down Expand Up @@ -34,9 +34,7 @@
// translates to 100
#define VARIANT_VERSION (VARIANT_MAJOR_VERSION*100000) + (VARIANT_MINOR_VERSION*100) + (VARIANT_PATCH_VERSION)

namespace util {

namespace detail {
namespace mapbox { namespace util { namespace detail {

static constexpr std::size_t invalid_value = std::size_t(-1);

Expand Down Expand Up @@ -545,6 +543,6 @@ operator<< (std::basic_ostream<charT,traits>& out, Variant const& rhs)
return out;
}

}
}}

#endif // UTIL_VARIANT_HPP
#endif // MAPBOX_UTIL_VARIANT_HPP

0 comments on commit df55ab6

Please sign in to comment.