-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove operator += and -=, can be added as use-specific use-case as f…
…ree operators
- Loading branch information
Showing
6 changed files
with
98 additions
and
156 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2016 Dr. Colin Hirsch and Daniel Frey | ||
// Please see LICENSE for license or visit https://github.com/taocpp/json/ | ||
|
||
#ifndef TAOCPP_JSON_INCLUDE_PAIR_HH | ||
#define TAOCPP_JSON_INCLUDE_PAIR_HH | ||
|
||
#include <string> | ||
#include <utility> | ||
#include <type_traits> | ||
|
||
#include "traits.hh" | ||
|
||
namespace tao | ||
{ | ||
namespace json | ||
{ | ||
template< typename T > | ||
struct pair | ||
{ | ||
mutable std::string key; | ||
mutable T value; | ||
|
||
template< typename U > | ||
pair( U && v ) : key( traits< typename std::decay< U >::type >::default_key ), value( std::forward< U >( v ) ) {} | ||
|
||
pair( std::string && k, T && v ) : key( std::move( k ) ), value( std::move( v ) ) {} | ||
pair( std::string && k, const T & v ) : key( std::move( k ) ), value( v ) {} | ||
pair( const std::string & k, T && v ) : key( k ), value( std::move( v ) ) {} | ||
pair( const std::string & k, const T & v ) : key( k ), value( v ) {} | ||
pair( const char * k, T && v ) : key( k ), value( std::move( v ) ) {} | ||
pair( const char * k, const T & v ) : key( k ), value( v ) {} | ||
}; | ||
|
||
} // json | ||
|
||
} // tao | ||
|
||
#endif |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2016 Dr. Colin Hirsch and Daniel Frey | ||
// Please see LICENSE for license or visit https://github.com/taocpp/json/ | ||
|
||
#ifndef TAOCPP_JSON_INCLUDE_SINGLE_HH | ||
#define TAOCPP_JSON_INCLUDE_SINGLE_HH | ||
|
||
#include <utility> | ||
|
||
#include "pair.hh" | ||
|
||
namespace tao | ||
{ | ||
namespace json | ||
{ | ||
template< typename T > | ||
struct single | ||
{ | ||
mutable T value; | ||
|
||
template< typename U > | ||
single( U && v ) : value( std::forward< U >( v ) ) {} | ||
|
||
single( std::initializer_list< pair< T > > && l ) : value( std::move( l ) ) {} | ||
single( const std::initializer_list< pair< T > > & l ) : value( l ) {} | ||
single( std::initializer_list< pair< T > > & l ) : value( l ) {} | ||
}; | ||
|
||
} // json | ||
|
||
} // tao | ||
|
||
#endif |
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